Unit 21 Process Management
Unit 21 Process Management
Process Management: Concept of Process, process queues, process Scheduling, Cooperating Process,
Threads, Inter-Process Communication, CPU scheduling Criteria, Scheduling algorithms, Multiple
Processor Scheduling, Real Time Scheduling, Algorithm Evaluation.
Process management
A program in execution is called a process. A process will need certain resources—such as CPU time,
memory, files, and I/O devices —to accomplish its task. These resources are allocated to the process
either when it is created or while it is executing.
There may exist more than one process in the system which may require the same resource at the same
time. Therefore, the operating system has to manage all the processes and the resources in a convenient
and efficient way.
Some resources may need to be executed by one process at one time to maintain the consistency
otherwise the system can become inconsistent and deadlock may occur.
The operating system is responsible for the following activities in connection with Process Management
1. Scheduling processes and threads on the CPUs.
2. Creating and deleting both user and system processes.
3. Suspending and resuming processes.
4. Providing mechanisms for process synchronization.
5. Providing mechanisms for process communication.
A process is the unit of work in most systems.
Systems consist of a collection of processes: operating-system processes execute system code,
and user processes execute user code.
All these processes may execute concurrently.
The process, from its creation to completion, passes through various states. The minimum number of states
is five.
1. New
A program which is going to be picked up by the OS into the main memory is called a new process.
2. Ready
Whenever a process is created, it directly enters in the ready state, in which, it waits for the CPU to be
assigned. The OS picks the new processes from the secondary memory and put all of them in the main
memory.
The processes which are ready for the execution and reside in the main memory are called ready state
processes. There can be many processes present in the ready state.
3. Running
One of the processes from the ready state will be chosen by the OS depending upon the scheduling
algorithm. Hence, if we have only one CPU in our system, the number of running processes for a particular
time will always be one. If we have n processors in the system then we can have n processes running
simultaneously.
4. Block or wait
From the Running state, a process can make the transition to the block or wait state depending upon the
scheduling algorithm or the intrinsic behavior of the process.
When a process waits for a certain resource to be assigned or for the input from the user then the OS move
this process to the block or wait state and assigns the CPU to the other processes.
5. Completion or termination
When a process finishes its execution, it comes in the termination state. All the context of the process (Process
Control Block) will also be deleted the process will be terminated by the Operating system.
6. Suspend ready
A process in the ready state, which is moved to secondary memory from the main memory due to lack of the
resources (mainly primary memory) is called in the suspend ready state.
If the main memory is full and a higher priority process comes for the execution then the OS have to make the
room for the process in the main memory by throwing the lower priority process out into the secondary
memory. The suspend ready processes remain in the secondary memory until the main memory gets available.
7. Suspend wait
Instead of removing the process from the ready queue, it's better to remove the blocked process which is
waiting for some resources in the main memory. Since it is already waiting for some resource to get
available hence it is better if it waits in the secondary memory and make room for the higher priority
process. These processes complete their execution once the main memory gets available and their wait is
finished.
Components of a Process
Data:- The global as well as static variables are included in this section.
Characteristics of a Process
All of the above attributes of a process are also known as the context of the process. Every process has
its own process control block(PCB), i.e. each process will have a unique PCB. All of the above attributes
are part of the PCB.
Process Control Block
Each process is represented in the operating system by a process control block (PCB)—also
called a task control block. It contains many pieces of information associated with a specific
process, including these:
Process state. The state may be new, ready, running, waiting, halted, and so on.
Program counter. The counter indicates the address of the next instruction
to be executed for this process.
CPU registers. The registers vary in number and type, depending on the
computer architecture. They include accumulators, index registers, stack pointers,
and general-purpose registers, plus any condition-code information. Along with
the program counter, this state information must be saved when an interrupt
occurs, to allow the process to be continued correctly afterward
CPU-scheduling information. This information includes a process priority, pointers to scheduling
queues, and any other scheduling parameters.
Memory-management information. This information may include such items as the value of the base
and limit registers and the page tables, or the segment tables, depending on the memory system used
by the operating system .
Accounting information. This information includes the amount of CPU and real time used, time
limits, account numbers, job or process numbers, and so on.
I/O status information. This information includes the list of I/O devices allocated to the process, a list
of open files, and so on.
the PCB simply serves as the repository for any information that may vary from process to process.
Process Scheduling
The processes that are residing in main memory and are ready and waiting to execute are kept on a list
called the ready queue.
This queue is generally stored as a linked list. A ready-queue header contains pointers to the first and final
PCBs in the list. Each PCB includes a pointer field that points to the next PCB in the ready queue.
The list of processes waiting for a particular I/O device is called a device queue. Each device has its
own device queue .
A common representation of process scheduling is a queueing diagram,
Fig:- Queueing-diagram representation of process scheduling
Each rectangular box represents a queue. Two types of queues are present: the ready queue and a set of
device queues. The circles represent the resources that serve the queues, and the arrows indicate the flow
of processes in the system.
A new process is initially put in the ready queue. It waits there until it is selected for execution, or
dispatched. Once the process is allocated the CPU and is executing, one of several events could occur:
• The process could issue an I/O request and then be placed in an I/O queue.
• The process could create a new child process and wait for the child’s termination.
• The process could be removed forcibly from the CPU, as a result of an interrupt, and be put back in the
ready queue.