• Sign In / Register
  • Language
    • English
    • Deutsch
    • Française
    • Español
    • Português
    • Italia
    • Русский
    • 日本語
    • 한국어
    • 简体中文
    • 繁體中文

Briefly describe the meaning and function of PCB.

  • March 11, 2021
  • 1441

In order to make each program participating in concurrent execution, including data can run independently, a special data structure must be configured for it in the operating system, called the process control block (PCB, ProcessControlBlock). There is a one-to-one correspondence between the process and the PCB, and the user process cannot be modified.


The role of the process control block PCB:

In order to facilitate the description of the system and the operation of the management process, a data structure is specifically defined for each process in the core of the OS-Process Control Block PCB (ProcessControlBlock). As a part of the process entity, PCB records all the information needed by the operating system to describe the current situation of the process and manage the operation of the process. It is the most important recorded data structure in the operating system. The role of PCB is to make a program (including data) that cannot run independently in a multi-program environment become a basic unit that can run independently, a process that can be executed concurrently with other processes.

(2) PCB can realize intermittent operation mode. In a multi-program environment, the program runs in a stop-and-go intermittent operation mode. When a process is suspended due to blocking, it must retain the CPU site information when it is running. After having the PCB, the system can save the CPU site information in the PCB of the interrupted process for use when the CPU site is restored when the process is scheduled for execution again. Therefore, it can be made clear again that in a multi-program environment, as a static program in the traditional sense, because it does not have the means to protect or save its own operating site, it cannot guarantee the reproducibility of its operating results, thus losing its operation. significance.

(3) PCB provides information needed for process management. When the scheduler schedules a process to run, it can only find the corresponding program and data according to the start address pointer of the program and data recorded in the PCB of the process in the memory or external storage; during the process of running, when the file needs to be accessed When the files or I/O devices in the system, they also need to rely on the information in the PCB. In addition, according to the resource list in the PCB, all the resources required for the process can be learned. It can be seen that during the entire life cycle of a process, the operating system always controls and manages the process according to the PCB.

(4) PCB provides information needed for process scheduling. Only processes in the ready state can be scheduled for execution, and the PCB provides information about what state the process is in. If the process is in the ready state, the system inserts it into the process ready queue and waits for the scheduler to schedule; in addition, it is often necessary to know other information about the process when scheduling. For example, in the priority scheduling algorithm, you need to know the process Priority. In some fairer scheduling algorithms, you also need to know the waiting time of the process and the events that have been executed.

(5) PCB realizes synchronization and communication with other processes. The process synchronization mechanism is used to realize the coordinated operation of various processes. When the semaphore mechanism is adopted, it requires that a corresponding semaphore for synchronization is set in each process. The PCB also has an area or communication queue pointer for process communication.

Information in the process control block:

In the process control block, it mainly includes the following information:

(1) Process identifier: The process identifier is used to uniquely indicate a process. A process usually has two kinds of identifiers: ① external identifiers. In order to facilitate the user process to access the process, an external identifier must be set for each process. It is provided by the creator and usually consists of letters and numbers. In order to describe the family relationship of the process, the parent process ID and the child process ID should also be set. In addition, a user ID can be set to indicate the user who owns the process. ②Internal identifier. In order to facilitate the use of the process by the system, an internal identifier is set for the process in the OS, that is, each process is given a unique digital identifier, which is usually the serial number of a process.

(2) Processor state: The processor state information is also called the context of the processor, which is mainly composed of the contents of various registers of the processor. These registers include: ①General-purpose registers, also known as user visible registers, which are accessible by user programs and used to temporarily store information. In most processors, there are 8 to 32 general-purpose registers. In RISC-structured computers There can be more than 100; ②Instruction counter, which stores the address of the next instruction to be accessed; ③Program status word PSW, which contains status information, such as condition code, execution mode, interrupt mask flag, etc.; ④User stack pointer, It means that each user process has one or several related system stacks, which are used to store process and system call parameters and call addresses. The stack pointer points to the top of the stack. When the processor is in the execution state, much of the information being processed is placed in the register. When the process is switched, the processor state information must be saved in the corresponding PCB, so that the execution can continue from the breakpoint when the process is re-executed.

(3) Process scheduling information: When the OS is scheduling, it is necessary to understand the status of the process and information about process scheduling. These information include: ① Process status, indicating the current status of the process, which is used as the basis for process scheduling and swapping ②Process priority is an integer used to describe the priority level of the process using the processor. The process with higher priority should get the processor first; ③Other information required for process scheduling, which is related to the process scheduling algorithm used For example, the sum of the time that the process has been waiting for the CPU, the sum of the time that the process has been executed, and so on; ④Event refers to the event waiting for the process to change from the execution state to the blocking state, that is, the cause of the blocking.

(4) Process control information: Refers to the information necessary for process control, which includes: ①The address of the program and data, the memory or external memory address of the program and data in the process entity, so that it can be scheduled to execute when the process is executed. , The program and data can be found from the PCB; ②Process synchronization and communication mechanism, which is a necessary mechanism for synchronization and process communication, such as message queue pointers, semaphores, etc., they may be placed in the PCB in whole or in part; ③Resource list, in which all the resources (except CPU) required by the process during its operation are listed, and there is also a list of resources allocated to the process; ④Link pointer, which gives the process ( PCB) The first address of the PCB of the next process in the queue.

Select Your Location