Process Management
Process Management
Process Management
In a multiprogramming environment, the OS decides which process gets the processor when and for how
much time. This function is called process scheduling. An Operating System does the following activities
for processor managements:
• Keeps track of processor and status of process. The program responsible for this task is known as traffic
controller.
• Allocates the processor (CPU) to a process.
• De-allocates the processor when a process is no longer required.
1. New State
When a process is first created, it occupied the created or new state.In this state, the process waits
admission to the ready state.This admission is approved or delayed is done by the software called Long
Term Scheduler.The operating system’s role is to manage the execution of existing and newly created
processes by moving them between the two states (Ready state, Swapped Out and Ready state) until they
finish.
2. Ready/ Suspend
If a process is in ready state, for a longer time that process moves to the virtual memory in order
to provide space for other high priority resources.The state of this process needs to be resumed,
when the main memory is ok. Then the state is changed again to ready state.
3. Ready State
The process that was at the new state next go to this state. A process in the ready state has been
loaded into main memory until it is executed by the CPU. This is an idle process which is always
ready to run, and never terminates.
4. Running State
This state is called an active or execution state which is executed in the CPU. When in this state,
if the process exceeds its allocated time period, it may be context switch and back to ready state
or temporarily move to blocked state.
5. Blocked/ Suspend
If the main memory is too loaded or to give the space to high priority processes,the processes
with block state in main memory are moved to virtual memory as swapped out and blocked
state.The state of this process needs to be resumed, when the main memory is ok.Then the state is
changed again to blocked state.
6. Blocked state
This state is called the Sleeping state. When a process comes to this state, it is removed from the
CPU and retained in the main memory.A process has to remain “blocked” until their resources
become available. Once the resources are obtained, the blocked process moves to ready state and
then to running state.
A process may be terminated either from the running state by completing its execution or killed.
Normally these processes are removed from the main memory and the processes which were not
removed are called “zombies”
A Process Control Block is a data structure maintained by the Operating System for every
process. The PCB is identified by an integer process ID (PID). A PCB keeps all the information
needed to keep track of a process as listed below.
Process State - The current state of the process i.e., whether it is ready, running, waiting, or
whatever.
Process ID - Unique identification for each of the processes in the operating system.
Program Counter - Program Counter is a pointer to the address of the next instruction to be
executed for this process.
CPU registers - Various CPU registers where processes need to be stored for execution for
running state.
Memory management information - This includes the information of page table, memory
limits, Segment table depending on memory used by the operating system.
I/O status information - This includes a list of I/O devices allocated to the process.
There are several steps involved in context switching of the processes. The following diagram
represents the context switching of two processes, P1 to P2, when an interrupt, I/O needs, or
priority-based processes occur in the ready queue of PCB.