Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities

Operating system process management

Basic concept of process: program, process, thread, pipe

Program execution

Forward graph: Directed acyclic graph used to describe the order of execution between parts of a process or program. Node: Represents a process, program segment, or statement.

Directed edge: indicates that there is a forward and successor relationship between two nodes.

If there is a sequential relationship between process Pi and Pj, it can be expressed as Pi→Pj, that is, Pi must be completed before Pj starts to execute

Pi is the direct precursor of Pj

Pj is the direct successor of Pi

The sequential execution of a program

In a multiprogram environment, there are several macroscopically executed programs at the same time over a period of time.

Advantages: convenient for programmers to detect and correct program errors. Disadvantages: Small system throughput. The resource usage is low.

Concurrent execution of a program:

Multi-program technology makes it possible for programs or program segments without precursors to execute simultaneously, and concurrent execution not only improves system performance, but also brings uncertainty to program execution.

In a multiprogram environment, there are several macroscopically executed programs at the same time over a period of time. In a single processor system, only one program is executed at any time, so multiple programs are executed alternately at different times on a micro level.

Concurrent execution of programs: While improving system performance, concurrent execution also brings uncertainty to program execution. Characteristics of the

Discontinuity: Concurrent programs share the entire machine resources and are mutually restricted. The execution process of a program may not be continuous.

Loss of closure: Execution of any program is affected by other concurrent programs.

Non-reproducibility: The execution result of any program is affected by the overall execution speed of concurrent programs.

Concurrent execution of programs: Characteristics

Non-reproducibility: Uncertainty in the value of a shared variable.

Concurrent execution of programs: While improving system performance, concurrent execution also brings uncertainty to program execution. Advantages Large system throughput. High resource utilization.

Disadvantages: mutual restriction between programs, correctness of the difficulty to ensure.

Concurrency and sharing are the two most basic characteristics of the operating system, that is, in the system (memory) at the same time there are a number of mutually independent programs, these programs in the system not only cross running, but also to share the resources in the system, which will cause a series of problems.

Competition for resources

Communication between running programs

Cooperation and collaboration between programs

The static concept of the program can not solve the existing problems, must introduce a dynamic concept that can describe the program in memory running state – process.

Process is introduced into

process

An execution of a program on a data set is an independent unit of system resource allocation and scheduling.

Structure features: it is composed of process control block (PCB), program and data.

Dynamic: The most basic characteristic of a process, a process of execution, with a life cycle.

Concurrency: Multiple process entities live in memory and can run simultaneously for a period of time.

Independence: A basic unit that can operate independently, allocate resources independently, and receive scheduling independently.

Asynchrony: Moving forward at independent and unpredictable rates.

The basic state

Ready: The process has all the necessary resources except the CPU and is ready to run as soon as it gains CPU control. A queue.

Execution: The process has obtained all the resources it needs to run, and the corresponding program is executing on the processor. A process.

Block: The state in which an executing process suspends execution and abandons the processor due to an event. Also called wait state. Multiple queues.

State transition