Operating system study notes-computer system overview

Computer system overview

1. Basic concepts of operating system

1.1, the concept of operating system

Operating system refers to a collection of programs that controls and manages the hardware and software resources of the entire computer system, rationally organizes and schedules the allocation of computer work and resources, and provides convenient interfaces and environments for users and other software . The most basic system software .

1.2 Characteristics of operating system

  • Concurrent
  • shared
  • virtual
  • asynchronous

1.3. The objectives and functions of the operating system

1.3.1. Operating system as the manager of computer system resources

  • Processor management

    Process control, process synchronization, process communication, deadlock handling, processor scheduling

  • Memory management

    Memory allocation, address mapping, memory protection and sharing, memory expansion

  • File management

    File storage space management, directory management and file read-write management and protection

  • Equipment management

    Buffer management, device allocation, device handling and virtual devices

1.3.2. Operating system as the interface between user and computer hardware

The interfaces provided by the operating system are mainly divided into two categories: one is the command interface, users use these operating commands to organize and control the execution of the job; the other is the program interface, programmers can use them to request the services of the operating system .

  • Command interface

    Online command interface and offline command interface

  • Program interface

    The program interface is composed of a set of system call commands . The user uses these system call commands in the program to request the operating system for its services.

1.3.3, operating system as an expansion machine

pass


2. Operating environment of the operating system

2.1 Operating mechanism of the operating system

In a computer system, the CPU usually executes two different types of programs: one is the kernel program of the operating system; the other is a program compiled by the user, that is, an application program . For the operating system, the functions of these two programs are different. The former is the manager of the latter. Therefore, the "management program" (that is, the kernel program) must execute some privileged instructions, while the "managed program" (that is, the application program) is For security reasons, these privileged instructions cannot be executed. The so-called privileged instructions refer to instructions that are not allowed to be used directly by users in the computer . Such as: I/O instructions, set interrupt instructions, access to registers used for memory protection, etc. In specific implementation, the state of the CPU is divided into user state and core state . When the CPU is in the core mode, it can execute privileged instructions, and when the CPU is in the user mode, it can only execute non-privileged instructions .

Now the operating system is basically hierarchical, and each function is set at different levels . Some modules closely related to the hardware , such as clock management, interrupt processing, device drivers, etc., are at the bottom . Followed by programs that run frequently, such as process management, memory management, and device management . These two parts constitute the kernel of the operating system, and the instructions of these two parts work in the core state . The kernel is the underlying module configured on the computer and is an extension of computer functions. Most operating system kernels include four aspects :

  1. Clock management

    Timing, process switching can be realized, etc.

  2. Interrupt mechanism

    Improve the CPU utilization in the multi-program running environment. Now the operating system is software driven by interrupts. In the interrupt mechanism, only a small part belongs to the kernel, they are responsible for protecting and restoring the interrupt scene, and transferring control to the relevant processing program . This can reduce the interrupt processing time and improve the parallel processing capabilities of the system.

  3. Primitive

    In an operating system designed according to a hierarchical structure, the bottom layer must be some public small programs that can be called, each of which completes a prescribed operation. Their characteristics are as follows:

    • At the top of the operating system, the part closest to the hardware;
    • The operation of these programs is atomic, and their operations can only be done in one go;
    • These programs have a short running time and are frequently called.

    The straightforward way to define primitives is to turn off interrupts .

  4. System control data structure and processing

    There are many data structures used to register status information in the system, such as job control block, process control block (PID), etc. In order to achieve effective management, the system needs some basic operations, common ones are:

    • Process management . Process state switching, process scheduling and dispatch, creation and cancellation of process control blocks;
    • Memory management . Memory space allocation and recovery, memory information protection program, code swap program, etc.;
    • Equipment management . Buffer management, equipment allocation, etc.

    In summary, the core state instructions actually include some system call instructions and some operation instructions for clocks, interrupts and primitives .

2.2. The concept of interrupts and exceptions

How to switch between core mode and user mode? The system does not allow user programs to implement core functions, and they must use these functions. Therefore, it is necessary to establish some "gates" in the core state in order to realize the transition from the user state to the core state . In the operating system, the only way for the CPU to enter these "gates" when running upper-level programs is through interrupts .

  • Interrupt

    Also called external interrupt, it refers to the occurrence of events other than the execution of instructions from the CPU , such as: I/O end interrupt generated by the device, indicating that the device input/output processing has been completed, and it is hoped that the processor can send the next input/output to the device. Output requests, while allowing the program to continue running after completing the input/output. Clock interruption means that a time slice has arrived, allowing the processor to process timing and start tasks that run at regular intervals. This series of interrupts is usually not related to the currently running program.

  • abnormal

    Also called internal interruption, trapping. Refers to events from within the CPU executing instructions , such as illegal operation codes of the program, address violations , arithmetic overflows, page faults in the virtual storage system, and special trapped instructions . The handling of exceptions generally depends on the operating site of the current program, and exceptions cannot be shielded, and they are handled immediately once they occur .

2.3, system call

The so-called system call refers to the user calling some sub-functions provided by the operating system in the program, and the system call can be regarded as a special public subroutine . The various shared resources in the system are managed uniformly by the operating system. Therefore, in the user program, all resource-related operations, such as storage allocation, I/O transmission, and file management, must be called to the operating system through system calls. The request is made and completed by the operating system . These system calls can be roughly divided into the following categories:

  • Equipment management . Complete the request and release of the device, and start the device;
  • File management . Complete file reading, writing, creation and deletion, etc.;
  • Process management . Complete process creation, cancellation, blocking and wake-up, etc.;
  • Process communication . Complete functions such as message transmission or signal transmission between processes;
  • Memory management . Complete memory allocation, recovery, and obtain the size and start address of the memory area occupied by the role.

System call-related functions involve operations such as resource management and process management, which have a great impact on the entire system, so certain privileged instructions must be used to complete. Therefore, the system call processing needs to be completed by the system kernel program, and it must run in the core state . The user program can execute the trap instruction (also called the access control instruction) to initiate system calls and request the operating system to provide services . It can be understood that: the user program executes the "trap instruction", which is equivalent to actively handing over the right to use the CPU to the operating system kernel program (the CPU state will actively enter the core state from the user state), and then the operating system kernel program will make a system call request Deal with it accordingly . Please note that the access control command is used in user mode, so it is not a privileged command .

Guess you like

Origin blog.csdn.net/qq_36879493/article/details/107856883