Every
Note: Don't confuse a process with a thread. A process is always composed of one or more threads.
Each Process ID maps onto a container-like memory block that contains the relevant information associated with the corresponding Process ID. This representation of the information is referred to as Process Control Block (PCB).
Some of the information stored in a PCB is shown in the diagram above and elaborated below:
Pointer It is a reference to the existing
Process State: The state of the process, which can vary from running, waiting, terminated, or blocked.
Process ID: The unique identifier of the process (and the Process Control Block).
Program Counter: It is a counter that refers to the memory address that stores the next instruction to be executed.
Registers: These are dedicated small and temporary data storage locations that can store process execution-relevant information. Memory Data Register and Memory Address Register are two examples of registers.
Memory Limits: This refers back to the page tables or memory references that are dedicated to the respective process.
List of Open Files: Files are the operating system's memory storage zones in the secondary storage devices. The list of relevant files flagged as accessible for the process is stored accordingly.
The implementation of the PCB can be abstracted in the form of a struct definition, as shown below:
#include <iostream>using namespace std;struct processControlBlock{void * stack; //stack pointerpid_t pid; // process idstruct files_struct *files; //pointer to files open// you can add more variables// to store process related information};int main() {processControlBlock instance_process;// your code goes herereturn 0;}
The code above is an example of an abstracted implementation of how a Process Control Block (PCB) can be implemented as a struct with member variables storing the process-related information.
Free Resources