Process Hierarchy
Let us discuss this with an example
• In unix this is done by the 'Fork' system call, which creates a 'child' process
and the 'exit system call', which terminates current process.
• The root of tree is a special process created by the operating system during
startup.
• A process can choose to wait for children to terminate.
• Example C issued a wait() system call it would block until G-Finished.
Process Control Block (PCB) in OS
A data structure retained by the OS for each process is known as a process control
block. Each PCB has its own integer process ID (PID) which is the identity of the PCB.
PCB is a collection of all the information regarding a process like the state of the
process, location of a process, etc. The lifetime of a PCB is as long as that of a process
i.e., till the OS terminates a process.
Following is the information that PCB keeps a track of:
• Process State: This is the current state of the process. It can be any state then, ready,
running, waiting, or any else.
• Process Privileges: This allows/disallows access to system resources.
• Process ID: Unique identification for each of the process in the operating system.
• Pointer: It is a pointer to the parent process.
• Program Counter: This points to the address of the next instruction that is to be
executed for a process.
Process Control Block (PCB) in OS
• CPU registers: This is where a process is stored before execution or entering the running state.
• CPU Scheduling Information: Stores process priority and other scheduling information necessary for
scheduling a process.
• Memory management information: This contains page table information, memory limits, and segment
table based on the memory used by the operating system.
• Accounting information: Stores information regarding the amount of times a processor is used for
process execution, time limits, execution ID, etc.
• I/O status information: The list of I/O devices allocated to the process is stored here.
Note:
The PCB is maintained for a process throughout its lifetime, and is deleted once the process terminates.
Attributes of a Process
A Process has various attributes associated with it. Some of the attributes of a Process are:
• Process Id: Every process will be given an id called Process Id to uniquely identify that process from the
other processes.
• Process state: Each and every process has some states associated with it at a particular instant of time. This is
denoted by process state. It can be ready, waiting, running, etc.
• CPU scheduling information: Each process is executed by using some process scheduling algorithms like
FCSF, Round-Robin, SJF, etc.
• I/O information: Each process needs some I/O devices for their execution. So, the information about device
allocated and device need is crucial.
Process Operations
After gaining insights on the architecture of a process and the various states a process go through, let us see
some of its operations:
• Creation: once a process is created, it’s ready to be landed in the ready queue i.e loaded onto the main memory,
thus, be ready for its execution.
• Scheduling: OS chooses a process from those present in the ready queue and starts its execution, this whole
process is called scheduling.
• Execution: once the process has been scheduled by the OS, the processor starts executing it. If during the
execution, the process enters a waiting or blocked state, then it means that the processor is executing other
processes.
• Killing: once the process finishes execution, the contexts of PCB get deleted and the process gets terminated by
the OS.
Different Times Concerning a Process in OS
Different times concerning a process in Operating System
• Burst time: The time required for the execution of the process
• Arrival time: The time at which the process enters the ready queue.
• Turnaround time: The time taken by a process from entering the ready state for the first time till
its exit time i.e., the difference between completion time and arrival time.
• Waiting time: The time spent by the process in ready state i.e., the difference between turnaround
time and burst time.
• Exit time: The time at which the process completes execution and exits the system.
• Response time: The time taken by a process, to be allocated to the CPU, for the first time after
entering ready queue i.e., the difference between the time a process first gets CPU and the arrival
time
• Throughput: This is a way to find the efficiency of a processor. It is the number of processes
executed by the CPU in a given amount of time.
Types of Process
CPU-Bound vs I/O-Bound Processes:
• A CPU-bound process requires more CPU time or spends more time in the running
state.
• An I/O-bound process requires more I/O time and less CPU time. An I/O-bound process
spends more time in the waiting state.