Operating System Basics-1

1. Operating System Overview

The role of the operating system: Improve the efficiency of the computer system through resource management, improve the human-machine interface, and provide users with a friendly working environment.

Characteristics of operating systems: concurrency, sharing, virtualization, uncertainty.

Functions of the operating system: process management, storage management, file management, device management, and job management.

Classification of operating systems: batch operating systems, time-sharing operating systems (using CPU work slices in turn), real-time operating systems (quick response), network operating systems, distributed operating systems (physically dispersed computer interconnection systems), microcomputer operating systems (Windows), embedded operating system.

The basic process of computer startup is: BOS->Master Boot Record->Operating System.

2. The composition and state of the process

The composition of the process: process control block PCB (unique sign), program (describe what the process is to do), data (store the data required for the process to execute)

The basic state of the process is the three-state diagram in the left picture below, which is only three states when the system is automatically controlled, and the five-state in the bottom right picture, there are two more states: static ready and static blocking, which need artificial The operation will enter the corresponding state, active ready means ready, active blocking means waiting.

It can be seen that after human intervention, the process will be suspended and enter a static state. At this time, manual activation is required to restore the active state, and the essence after that is still a three-state graph.

3. Predecessor Diagram

Used to indicate which tasks can be executed in parallel and which tasks have a sequential relationship, for example:

4. Process resource graph

Process resource graph: It is used to represent the allocation and request relationship between processes and resources.

E.g:

P stands for process, R stands for resource, and there are several spheres in the R box to indicate that there are several such resources. In the figure, R1 points to P1, indicating that R1 has a resource allocated to P1, and P1 points to R2, indicating that P1 also needs to request an R2 resource to execute

Blocking node: All resources requested by a process have been allocated, and the required resources cannot be obtained. The process is blocked and cannot continue. 2 as shown above.

Non-blocking node: The resources requested by a process still have remaining resources, which can be allocated to the process to continue running. As shown in the figure above P1, P3.

When all processes in a process resource graph are cold-blocking nodes, it falls into a deadlock state.

The method of simplifying the process resource graph : first look at how many resources are left unallocated in the system, then look at which processes are not blocking, then remove all edges of the non-blocking processes to form an isolated point, and then put the system The resources allocated to this process are recovered, so that the remaining free resources of the system will increase, and then we will go to see which of the remaining processes are non-blocking, and then turn them into isolated points one by one. In the end, all resources and processes become isolated points. In the figure, p3 does not block the cold, so P3 is the beginning of the simplified diagram. It isolates P3 and recycles the resources allocated to him. It can be seen that P1 has also become a non-blocking node, so P3, P1, and P2 are possible. .

5. Synchronization and Mutual Exclusion

Mutual exclusion: A resource (that is, a critical resource) can only be used by one task at the same time. It needs to be locked when used, and unlocked after use can be used by other tasks; such as a printer.

Synchronization: Multiple tasks can be executed concurrently, but there are differences in speed. Under certain circumstances, they stop and wait, and there is no question of whether resources are separate or shared; such as bicycles and cars.

Critical resource: A resource that needs to be accessed in a mutually exclusive manner between processes.

Critical section: Refers to the program in the process that operates on critical resources. Essentially a piece of program code.

Mutual exclusion semaphore: Mutual exclusion access is used for critical resources. After using the mutex semaphore, other processes cannot access it. The initial value is 1.

Synchronization semaphore: access control to shared resources, the initial value is generally the number of shared resources.

Guess you like

Origin blog.csdn.net/flysh05/article/details/124124335