Computer Operating Systems Chapter 1

Introduction to operating systems

1.1 The goals and functions of the operating system

Definition:The operating system is the hardware and software that controls and manages the computer system, and allocates and schedules resources Software.

Goals:Convenience, effectiveness (increasing the utilization of system resources and improving system throughput), scalability, openness sex.

1.2 The role of operating system

  1. Unified management of computer resources: processor resources, IO device resources, memory resources, file resources;

  1. Implements the abstraction of computer resources: IO device management software provides read and write interfaces, and file management software provides operation file interfaces;

  1. Provides the interface between the user and the computer: GUI (graphical user interface), command form, system call form.

1.3 Development motivation

The driving force for OS development Improving computer system resource utilization | Convenience for users | Continuous upgrading of devices | Continuous development of computer architecture | Continuously proposing new application requirements

2.1 Development process of operating system

The development history of OS

[1945 manual operation method]

[Offline I/O in the 1950s]

Operation: Solve the conflict between man and machine and the speed mismatch between CPU and I/O. The input and output of programs and data are completed without the host computer.

Online I/O: I/O that occurs under the direct control of the host.

Advantages of offline I/O: reduced CPU idle time and increased IO speed

[Single-channel batch processing system in the mid-1950s]

Operation: Input a batch of jobs to the tape in offline IO mode, and equip the system with a supervisory program. Under the control of the program, the jobs are completed one by one, and only one job is always saved in the memory.

Advantages: Improve system resource utilization and system throughput.

Disadvantages: Still not fully utilizing system resources, resulting in a waste of computer memory

[Mid-1960s multi-pass batch processing system]

Operation: Jobs are first placed in external storage and arranged into a queue (backup queue). The job scheduler selects several jobs from the queue and transfers them into the queue according to a certain algorithm, so that they can share the CPU and various resources in the system.

Advantages: high resource utilization, high system throughput, long average turnaround time, no interactive capabilities

Issues to be solved: Processor requisition issues, memory allocation and protection, IO device allocation, file organization and management issues, job management, user and system interfaces

【Time Sharing System】

Reasons for development: To meet users’ requirements for human-computer interaction

Operation: In order to achieve human-computer interaction, the original batch processing system operation method must be abandoned and adopted: ① the job enters the memory directly, because the job cannot run on the disk; ② adopts rotation operation to ensure that each job has a chance to run, Therefore, the concept of time slices was introduced

Features: multi-channel (multiple terminals are connected to the same host), independence (the respective terminals do not interfere with each other), timeliness (response time is 1-3s), interactivity

【Real-time system】

Definition: The OS can respond to external event requests in a timely manner, complete event processing within the specified time, and control all real-time tasks to run in a coordinated manner

Types of real-time OS: industrial control OS, information query OS, multimedia OS, embedded OS

Types of real-time tasks: periodic/aperiodic real-time tasks, hard real-time tasks (Hard real time, HRT), soft real-time tasks SRT (the above four task types are all accompanied by deadlines)

Features: multi-channel (periodically collects multi-channel on-site information and controls multiple actuators), independence (respective terminals do not interfere with each other), timeliness (response time is milliseconds), interactivity, and reliability sex

The two basic characteristics of real-time systems are: timeliness and reliability

3.1 Basic characteristics of operating systems

3.1.1 Concurrency

  • Concurrency (parallelism occurs at the same time, concurrency occurs at the same time interval):

  • Concept: Macroscopically, multiple programs are running at the same time, but microscopically, only one program is running at a time. What we call concurrency generally refers to the concurrency of processes.

3.1.2 Sharing

shared:

Concept: OS sharing refers to the reuse of resources: for the common use of multiple concurrently executing processes in the memory (that is, limiting the time and limiting the location)

Type: mutually exclusive sharing (B can access only after A has accessed it), "simultaneous" sharing (used together at the macro level and alternately at the micro level)

Concurrency and sharing are the two most basic features of multitasking OS, and they are the conditions for each other's existence. The sharing of resources is conditioned on the concurrent execution of processes; at the same time, if resource sharing cannot be coordinated, the speed of concurrency will be affected.

3.1.3 Virtual

Virtuality: manifested by transforming a physical entity into several logical entities.

Time-division multiplexing technology: Resources are multiplexed in time, different programs are used concurrently, and multiple programs use the computer's hardware resources in a time-shared manner to improve resource utilization.

Space division multiplexing technology: used to implement virtual disks (physical disks are virtualized into logical disks, C disk, D disk, etc. on the computer), virtual memory (logically expand the storage capacity of the program), etc., to improve resource utilization. Improve programming efficiency.

3.1.4 Asynchronous

In a multiprogramming environment, multiple processes are allowed to execute concurrently, but due to resource limitations and other factors, the execution of the process runs in a "stop-and-go" manner, and each process The execution status (running, pause, speed, completion) is alsounknown.

4.1 Operating environment of the operating system

Operating system interrupt handling

Operating system interrupt handling

The role of the interrupt mechanism: to allow users to interact in a multi-channel batch processing system;

Interrupt generated:

When an interrupt occurs, the CPU immediately switches to the supervisory state to carry out management work; (the supervisory state is also called the privileged state, system state or core state, which is the state of the machine when the program managed by the operating system is executed.)

After an interrupt occurs, the currently running process will be suspended and the operating system kernel will handle the interrupt;

Different interrupt signals will be processed differently.

Interruption categories:

Internal interrupt (also called "exception", "exception", "trap") ------- Signal source: Internal CPU, related to the currently executed instruction;

External interrupt (interrupt) ----------Signal source: external to the CPU, has nothing to do with the currently executing instruction.

External interrupt processing process:

After each instruction is executed, the CPU needs to check whether there is an external interrupt signal;

If an external interrupt signal is detected, you need to protect the CPU environment of the interrupted process (such as program status word PSW, program counter PC, various general-purpose registers) and store them in the PCB (process control block);

Transfer to the corresponding interrupt handler according to the interrupt signal type;

Restore the CPU environment of the original process and exit the interrupt, then return to the original process to continue execution.

5.1 Main functions of the operating system

Processor management functions

Essence: In traditional multiprogramming systems, the allocation and operation of processors are based on processes, so the management of processors can be attributed to the management of processes.

Function: process control, synchronization, communication, scheduling

Memory management functions

Functions: Memory allocation and recycling (static, dynamic allocation), memory protection (① each user program only runs in its own memory, ② users are not allowed to access OS programs and data), address mapping, memory expansion (virtual storage technology: request transfer function, replacement function)

Device management function

Functions: Buffer management, device allocation, device processing

File management function

Functions: File storage space management, directory management, file read and write management and protection

Interface management function

Function: OS provides users with the "interface between the user and the OS", which is divided into user interface (online user interface, offline user interface, graphical user interface) and program interface

6.1 Structure of operating system

simple structure

Modular structure:

Advantages: Improve the accuracy, understandability, maintainability and adaptability of OS design, and accelerate the OS development process

Disadvantages: It is difficult for interface regulations to meet the actual needs of modules for interfaces after division; decision B must be based on decision A, and there is no reliable decision sequence, which can easily lead to disordered decisions.

Hierarchical structure:

Advantages: Guaranteed accuracy, easy maintenance, scalability

Disadvantages: low system efficiency

Microkernel structure:

Concept: small enough kernel, client/server-based model, adopting the principle of separation of strategies and mechanisms, and using object-oriented technology;

Functions: process (thread) management, low-level memory management, interrupt and trap handling (in the microkernel OS, only a small part of the mechanism is placed in the kernel, and most of it is placed outside the microkernel) in various servers)

Advantages: Improve system scalability, reliability, and portability, provide support for distributed systems, and incorporate object-oriented technology. The operating system can adapt to the needs of different applications simply by adjusting policies

Existing problems: Because messages are passed between clients and servers, the operating efficiency of microkernel OS is lower than that of early OSs (a larger kernel means higher efficiency but takes up more space, otherwise it is less efficient but takes up less space)

Outer core structure:

Concept: The kernel does not provide abstract things such as processes and virtual memories of traditional OS, but focuses on the isolation (protection) and reuse of physical resources. That is, a very small kernel is responsible for protecting system resources, while the management responsibilities of hardware resources are delegated to app. Provide functions originally belonging to the OS kernel to users in the form of libraries

7.1 System calls

system call

Concept: Allow applications to call related processes in the OS through system calls, and then obtain corresponding services.

System calls are implemented through the interrupt mechanism

Different from general procedure calls:

①Run in different system states: The calling program of the system call runs in the user state, while the called program runs in the kernel state.

② Because the calling and running system states are different (one is user state, the other is kernel state), it is not allowed to directly transfer from the calling process to the called process. It is necessary to first transfer from user mode to kernel state through the soft interrupt mechanism, and then undergo kernel analysis. Only then can it be transferred to the corresponding system call processing subroutine.

③Return to the question: Each call needs to determine the priority

④Nested calls: System calls have certain restrictions on the depth of nested calls, but general procedure calls do not.

Types of system calls:

①Process control system calls

②File manipulation system calls

③Process communication system calls

Guess you like

Origin blog.csdn.net/CYwxh0125/article/details/129270415
Recommended