Operating System Process Composition
In most cases, the process we often talk about is actually a "process entity ". What is a process entity? A process entity consists of a program segment, a related data segment, and a PCB. In earlier UNIX versions, these three components were called "process images ". What we call creating a process is essentially creating a PCB in a process entity.
Today, we mainly introduce the main character in the process entity-PCB, program segments and related data segments. These are the code segments in the process and their corresponding configuration information, which are rarely involved in operating system scheduling, PCB is closely related. Next let's look at what is PCB.
Process Control Block (PCB)
A PCB is a data structure defined by the system for each process. It records the information required by the operating system to describe the current situation of the process and control the operation of the process.
All information. The role of a process control block is to make a program (including data) that cannot be run independently in a multi-program environment, and become a basic ticket that can run independently.
A process that can be concurrently executed with other processes, or the OS controls and manages the processes that are concurrently executed based on the PCB. It includes
The following four aspects
Process identifier is used to uniquely identify a process. A process usually has two identifiers:
(1) internal identifier
In all operating systems, each process is assigned a unique digital identifier, which is usually the serial number of a process. Internal identifiers are configured to facilitate system usage.
(2) External identifier
It is provided by the Creator, usually composed of letters and numbers. It is often used by users (processes) to access the process. To describe the family relationship of processes, you should also set the parent process ID and child process ID. You can also set a user ID to indicate the user that owns the process.
Processor status
The processor status information is mainly composed of the content in various registers of the processor. Many information is stored in registers when the processor is running. When the processor is interrupted, all this information must be stored in the PCB so that the process can continue to be executed from the breakpoint when it is re-executed. These registers include: ① general registers, also known as user visual registers, which are accessible by user programs and used for temporary information storage. In most processors, there are 8 ~ 32 General registers, which can contain more than 100 in a computer with a hierarchical structure; ② the instruction counter stores the address of the next instruction to be accessed; ③ the program status word PSW, it contains status information, such as the condition code, execution method, and interruption blocking sign. ④ a user Stack pointer indicates that each user process has one or more related system stacks, used to store process and system call parameters and call addresses. The stack pointer points to the top of the stack.
Process scheduling information
Some information related to process scheduling and process switching is also stored in the PCB, including: ① Process status, indicating the current state of the process as the basis for process scheduling and switching; ② process priority, which is used to describe an integer whose priority is the processor. Processes with a higher priority should obtain the processor first. ③ other information required for process scheduling, they are related to the process scheduling algorithm used, for example, the total time of the Process waiting for CPU, the total time of the process executed, and so on; ④ event, the event that the process is waiting for from execution to blocking, that is, the cause of blocking.
Process control information
Process control information includes: ① the address of the program and data, that is, the memory or external location (first) Address of the program and data of the process, so that the process can be scheduled to run, programs and data can be found from the PCB. ② Process Synchronization and communication mechanisms refer to the mechanisms necessary for Process Synchronization and Process Communication, such as Message Queue pointers and semaphores, they may be stored in the PCB in whole or in part; ③ a list of resources, that is, a list of all resources required by the process except the CPU and the resources allocated to the process; ④ link pointer, which gives the first address of the PCB of the next process in the queue where the process (PCB) is located.
Ps: in the operating system, a PCB with a uniform State usually exists in the link mode or in the cable insertion mode.