System Overview

System Overview

The operating system is the basic software that controls and manages system resources, organizes and dispatches computer resource allocation reasonably, provides an environment for users and other software interfaces, and the basic software of the system. Functions provided by the operating system: processor management, memory management, file management, and device management. The operating system provides convenient and easy-to-use services to the upper layer-encapsulated thought
GUI : graphical user interface command interface online command interface = interactive command interface offline command interface = batch command interface program interface: write code indirectly using printf function call System calls of the operating system (generalized instructions) bare metal + operating system -> virtual machine, expansion machine
Insert picture description here

Four characteristics of operating system

Concurrency, sharing, (the most basic feature, mutual condition) virtual, asynchronous

Concurrency : Two or more times occur at the same time interval, at the same time on the macroscopic level, and alternately on the micro level. Parallel : Two or more events occur simultaneously at the same time.

Single-core cpu can only execute one program at a time, and multi-core can parallel multiple programs.

Sharing : Resource sharing, resources can be used by multiple concurrent execution processes in total memory.

Mutually exclusive sharing : only one process is allowed to access resources for a period of time

Simultaneous sharing : multiple processes can access "simultaneously" in a period of time

Virtual : refers to the transformation of a physical entity into several logical counterparts. The physical entity (the former) actually exists, while the logical counterpart (the latter) is felt by the user. (Virtual storage technology, "space division multiplexing" "virtual storage time division multiplexing technology> virtual processor)

Asynchronous : It means that in a multi-program environment, multiple programs are allowed to execute concurrently, but due to limited resources, the execution of the process is not consistent to the end. Instead, it stops and moves forward at an unpredictable speed. This is The asynchronous nature of the process.

Operating system development

1. Manual operation stage : the user monopolizes the entire machine and the human-machine speed contradiction results in extremely low resource utilization
2. Batch processing stage : the introduction of offline input/output technology (completed with peripheral machine + tape), and is controlled by the supervisory program enter the job, output single-batch main advantages : ease to a certain extent contradictory human speed, resource utilization has improved. The main disadvantage : Only one program can run in the memory, and the next program can only be loaded after the program is finished. The CPU has a lot of time in idle waiting for I/O to complete. Resource utilization is still very low. The main advantages of multi-pass batch processing : concurrent execution of multi-pass programs and sharing of computer resources. Resource utilization has been greatly improved, CPU and other resources can be kept "busy", and system throughput has increased. **Main disadvantages: **User response time is long and there is no human-computer interaction function (the user can only wait for the computer to complete processing after submitting his own job, and cannot control his own job execution in the middle. For example: unable to debug the program/cannot run in the program Enter some parameters during the process)
3. Time-sharing operating system : The computer serves each user/job in turn in units of time slices, and each user can interact with the computer through the terminal. Main advantages: User requests can be responded to immediately, which solves the problem of human-computer interaction. Multiple users are allowed to use a computer at the same time, and the users' operations on the computer are independent of each other, and they cannot feel the presence of others. Main shortcomings: Some urgent tasks cannot be handled first. The operating system is completely fair to each user/job, cyclically serving a time slice for each user/job, and does not distinguish the urgency of the task.
4. Real-time operating system : Main advantages: It can respond to some urgent tasks first, and some urgent tasks do not need time slices to queue. Under the control of the real-time operating system, the computer system processes the event in time after receiving the external signal, and must process the event within a strict time limit. The main characteristics of real-time operating systems are timeliness and reliability (hard real-time, soft real-time)
5. Other operating systems : network operating systems, distributed operating systems, personal computer operating systems.
Insert picture description here

Operating mechanism of the operating system

C language code (high-level language) compiles machine instructions (binary) Instructions: cpu can recognize the most basic commands executed. Application program, operating system kernel program (kernel) privileged instructions (cpu cleared), non-privileged instructions (addition and subtraction instructions) cpu kernel mode: It means that the kernel program is running at this time, and privileged instructions can be executed at this time. User mode: Explain that the application program is running at this time, and only non-privileged instruction program status word register (PSW) can be executed at this time. There is a binary bit, 1 means "kernel mode", 0 means "user mode"
alias: kernel mode = Core state = management state; user state = target state. The user mode encounters a privileged instruction and generates an interrupt signal. PSW immediately switches to the kernel mode and then processes interrupts and exceptions of the operating system.
Insert picture description here

Interrupts and exceptions

The function of interrupt : "Interrupt" will cause the CPU to change from user mode to kernel mode, so that the operating system will regain control of the CPU, and multiple programs will be concurrent.
Type of interrupt : Internal interrupt : Also called exception. The exception is related to the currently executed instruction. The interrupt signal comes from the CPU internal (user mode executes privileged instructions, trapped instructions (request operating system kernel services) or non-issued instructions).
External interrupts : also It is said that the interrupt has nothing to do with the currently executed instruction. The interrupt signal comes from outside the CPU (clock interrupt signal, input and output signal). Abnormal : trapped (intentionally caused by the instruction, requesting kernel service), fault (can be repaired by the kernel, and the application continues after the repair Execution), termination (the kernel cannot be repaired, directly terminates the program, such as using illegal privileged instructions and integer division by 0)
The basic principle of the interrupt mechanism : Different interrupt signals need to be processed by different interrupt handlers. When the CPU detects the interrupt signal, it will query the " interrupt vector table " according to the type of the interrupt signal to find the storage location of the corresponding interrupt handler in the memory.
Insert picture description here

System call

"System call" : It is an interface provided by the operating system to applications (programmers/programmers). It can be understood as a special function that can be called by the application. The application can request the kernel of the operating system through a system call. service.
System call classification (function): device management, file management, process control, process communication, memory management
System call process: pass system call parameters -> execute trapped instructions (user mode) -> execute the corresponding internal request core program processing system Call (core state) -> return to the application.
Insert picture description here

Operating system architecture

Large kernel, single kernel, macro kernel, and
micro kernel
primitives are special programs that can be completed in one go without interruption. The kernel is the most basic and core part of the operating system. The programs that implement the kernel functions of the operating system are kernel programs.
The big kernel includes : clock management, interrupt processing, primitives, memory management, process management, and device management.
Microkernel : clock management, interrupt processing, primitives.
The process of perversion is costly and takes a lot of time. Frequent perversion will reduce system performance.
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44518702/article/details/109900378