Operating System-Computer System Overview

1. Basic concepts of computer system

Operating system concept

操作系统(Operating System,OS) 是指控制和管理整个计算机系统的硬件和软件资源,并合理地组织调度计算机的工作和资源的分配,以提供给用户和其他软件方便的接口和环境,它是计算机系统中最基本的系统软件。

Operating system characteristics

Concurrent

Concurrency: 指两个或多个事件在同一时间间隔内发生。这些事件宏观上是同时发生的,但微观上是交替发生的

The difference between the same time interval (concurrency) and the same time (parallel): In a multi-program environment, macroscopically, there are multiple programs executing at the same time, and at each moment, only one program is executing in a single-processor environment.

The concurrency of the operating system refers to the existence of multiple running programs in the computer system at the same time, which can be realized through time sharing.

shared

共享即资源共享,是指系统中的资源可供内存中多个并发执行的进程共同使用。

The so-called "simultaneous" is often at the macro level, and at the micro level, these processes may alternately access the resource (that is, time sharing)

Insert picture description here

virtual

Virtuality refers to the transformation of one physical entity into thousands of logical counterparts. The physical entity (the former) actually exists, while the logical counterpart (the latter) is felt by the user.

Insert picture description here

asynchronous

Asynchrony 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, but stops and goes forward at an unpredictable speed. This is the process The asynchronous nature.

The objectives and functions of the operating system


Insert picture description here
The interface between the system resource manager user and the computer hardware
Insert picture description here
Command interface: allows users to call directly. Online command interface (say one sentence and do one sentence), offline command interface (say a bunch and do a bunch).
Program interface: Indirect call through the program, composed of a set of system calls (program interface=system call)

Used as an expansion machine

Insert picture description here

2. The development and classification of operating systems

Manual operation stage

All the user's work on the computer requires manual intervention.

Disadvantages: The user monopolizes the entire machine, and the resource utilization is low. The CPU waits for manual operation and is not fully utilized.

Batch phase

Introduce offline input/output technology (completed with tape), and supervise the program responsible for controlling the input and output of the job (the prototype of the operating system).

Single-pass batch processing system

A certain degree of contradiction between human and machine speed has been alleviated, and resource utilization has been improved.

Main disadvantages: Only one program can run in the memory, and the next program can be loaded only after the program has finished running. The CPU has a lot of time in idle waiting for I/O to complete.

Multi-pass batch processing system

Insert picture description here

Multiple programs are executed concurrently, sharing computer resources. Resource utilization has been greatly improved, CPU and other resources remain "busy", and system throughput has increased.

The main disadvantages: long user response time and no human-computer interaction function (the user can only wait for the computer to complete the processing after submitting his own job, and cannot control the execution of his own job in the middle).

Time-sharing operating system

计算机以时间片为单位轮流为各个用户/作业服务,各个用户可通过终端与计算机进行交互。

Main advantages: User requests can be responded to immediately, which solves the problem of human-computer interaction. Allow multiple users to use a computer at the same time.

Disadvantages: Can't prioritize some urgent tasks. 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.

Real-time operating system

Insert picture description here

Other operating systems

Network operating system

It was born with the development of computer networks, which can organically combine computers in the network to realize data transmission and other functions, realize the sharing of various resources in the network (such as file sharing) and the communication between computers.

Distributed operating system

The main feature is distribution and parallelism. Each computer in the system has the same status, and any work can be distributed on these computers, and they can complete this task in parallel and cooperatively.

Personal computer operating system

Such as Windows, MacOS.

3. Operating environment of the operating system

mechanism

Two instructions

Simply put, "instructions" are the most basic commands that the processor (CPU) can recognize and execute.

There are two types of instructions:, 特权指令such as memory cleaning instructions and 非特权指令, such as addition and subtraction instructions. The former does not allow user programs to use it.

The difference between computer instructions and the code we write: A code in a high-level language may correspond to multiple instructions when translated

Two processor states

Insert picture description here
Two procedures

Insert picture description here

Operating system kernel

内核就是计算机上配置的底层软件,是操作系统最基本最核心的内容。实现内核功能的程序就是内核程序。

Insert picture description here

Clock management

The first function of timing requires time management to provide users with standard system time. Through the management of clock interruption, process switching can be realized.

For example: use time slice rotation scheduling in a time-sharing operating system, and measure the running degree of a job through clock management in a batch processing system.

Interrupt mechanism

Increase the CPU utilization rate in the multi-program running environment. A small part of the functions in the interrupt mechanism belong to the kernel. They are responsible for protecting and restoring the information at the interrupt site and transferring control to related programs.

Primitive

It is a public small program that can be called at the bottom.

  • At the bottom, the part closest to the hardware
  • Program operation is atomic
  • Run time is shorter and more frequent

The direct way to define primitives is to close the interrupt, and open the interrupt after all its actions are completed indivisible

System control data structure and processing

There are many data structures used by the system to register status information, such as job control blocks, process control blocks, various linked lists, message queues, and so on. There are three common operations:

  • Process management: process state management, scheduling, dispatching, creating and revoking process control blocks
  • Memory management: memory space allocation and recycling, memory information protection program
  • Equipment management: buffer management, equipment allocation and recycling, etc.

The concept of interrupts and exceptions

Insert picture description here

  • When an interrupt occurs, the CPU immediately enters the core state
  • When an interrupt occurs, the currently running process is suspended, and the operating system kernel handles the interrupt
  • Different interrupt signals will be processed differently

发生中断意味着,需要操作系统介入,开展管理作用。

用户态→核心态,唯一途径是 中断,核心态→用户态的切换是通过执行一个特权命令。将程序状态字(PSW)的标志位设置为用户态

Because the management work of the operating system (such as process switching, allocating I/O devices, etc.) requires the use of privileged instructions, the CPU must be converted from the user mode to the core mode. Interrupts can switch the CPU from user mode to core mode, allowing the operating system to gain control of the computer. With interrupts, concurrent execution of multiple programs can be realized.

Note: The handling of exceptions cannot be shielded, and it depends on the running site of the current program.

External interrupt processing

Insert picture description here

  1. Off interrupt

After the CPU responds to the interrupt, it must first protect the scene and cannot respond to more advanced interrupt requests

  1. Save breakpoint

Save the program breakpoint, that is, the program counter PC

  1. Lead interrupt service routine

The essence is to take out the entry address of the interrupt service program and send it to the program counter PC

  1. Save site and shield words

After entering the program interrupt service, you must first save the scene, which generally refers to the contents of the program status word register PSWR and some general-purpose registers

  1. Open interrupt

Allow more advanced interrupt requests to be responded

  1. Execute interrupt service routine

Is the purpose of program interruption

  1. Off interrupt

Ensure that it will not be interrupted when restoring the scene and shielding words

  1. Restore scene and shield word

Restore the scene and shield words to their original state

  1. Open interrupt, interrupt return

Interrupt return instruction, return to the breakpoint of the original program, in order to continue execution

System call

系统调用就是用户在程序中调用操作系统提供的一些子功能。

The various shared resources in the system are under the unified control of the operating system. Therefore, in the user program, all resource-related operations (such as storage allocation, I/0 operations, file management, etc.) must be operated by system calls. The system makes a service request and the operating system completes it on its behalf. This can ensure the stability and safety of the system

Insert picture description here

传递系统调用参数→执行陷入指令(用户态)→执行系统调用相应服务程序(核心态)→返回用户程序
Insert picture description here

Note: The trapping instruction is executed in the user mode, and an internal interrupt will be triggered immediately after the trapping instruction is executed. The system call request is issued in the user state, and the corresponding processing of the system call is performed in the core state. The trap instruction is the only instruction that can only be executed in the user mode, but not in the core mode.

Insert picture description here

Fourth, the operating system architecture

### Big core and micro core

Guess you like

Origin blog.csdn.net/weixin_45605341/article/details/112762620