1.3 Different Types of Process and Its Types in Operating System
1.3 Different Types of Process and Its Types in Operating System
➢ Process:
• A process is instance of a computer program that is being executed or A process is a program in
execution mode.
• One by one all instructions are read from the program and specified operations are performed.
• A process is dynamic/Active entity. It changes its states during its time duration of execution. It
takes birth (creation), lives (execution) and dies (termination).
• A process has limited life span. It starts when program is executed. It performs various operations
specified by instruction given in program and terminate once all instructions get executed.
• A process contains various resources like memory, disk, printer, scanner etc. as per its
requirement.
• A process contains memory space which is called address space. It is a list of memory locations
(addresses).
• Address space contains three parts:
o Code: It contains executable statements.
o Data: It contains global variables.
o Stack: It contains temporary data such as method parameters, return addresses and local
variables.
➢ Program:
• A program is an organized collection of instructions.
• A program is a static/passive entity. Once user writes a program, it will remain as it is until user
modifies it.
• A program has a longer life span. Once a program is written in some file and stored on disk, it
remains there till file is not deleted.
• A program is stored on disk in a file. It doesn’t contain any other resources.
• A program contains memory space on disk to store all the instruction only.
Page 1
• CPU can do only one work at a time. It cannot execute more than one instruction at the same time.
So, the CPU can handle only single process at a time.
• CPU is multiplexed in TIME among several processes which are loaded in main memory.
• Processes take turn to use CPU. One process is selected to use the CPU and it will be executed.
Other processes will wait for the CPU to become free.
• When currently running process waits for some event, such as I/O operation, CPU becomes free.
• Now, another process is selected to use the CPU. This cycle continues to execute all processes.
• This explains in following diagram, Suppose word start its execution, after some time it allocate CPU
to printing process and it will start execution. When fix time of process is complete at that time CPU
allocate to download process. This cycle continues till execution of all processes get complete.
Page 2
New Admitted Terminated
Scheduler Time -Out
Error/Kill/
Complete
Ready Running
Scheuler Dispatch
I/o or event
I/o or event Wait
completion
Waiting
1) New:
• When a process is first created, it occupies ‘New’ state. In this state, process awaits to enter in
‘Ready’ state.
2) Ready:
• A process which is in the ‘Ready’ state has been loaded into main memory. In this state, process
awaits for execution on a CPU. It is possible that more than one process may be in ‘Ready’ state at
a time.
3) Running:
• A process which is in the ‘Running’ state is currently executing on a CPU. In a one processor system,
one and only one process can be in this state at a time.
4) Waiting:
• A process which is in the waiting state is waiting for some I/O completion or some event to occur.
• For example, consider that some process requires printer to print documents but printer is being
used by some other process. So, process will wait and it will be in this state till the printer
becomes free.
5) Terminated:
• When process terminates, it acquires this state. A process can terminate by completing its
execution, or it can be killed by another process or some error.
Page 3
• These state transitions occur on various events. Such events and corresponding state transition
are described in the following table.
From State Event To State
New Admitted Ready
Ready Scheduling Running
Running Need I/O Waiting
Running Scheduler Time-Out Ready
Running Error/Kill/Complete Terminated
Waiting I/O or Event Completion Ready
Page 4
• I/O operation involves operations either related to reading an input from some device or a file, or
writing an output to some device or a file.
• Process alternates its execution between CPU burst and I/O burst.
• In CPU burst, it acquires CPU and instructions are executed sequentially. Process will be in
‘Running’ state during CPU burst.
• In I/O burst, process waits for some I/O operation to complete and CPU becomes free. Process will
be in ‘Waiting state’. This free CPU can be allocated to other process to allow it to run.
• Depending upon the behavior of execution, processes can be classified as-
1) CPU bound process
o It contains long CPU burst and thus infrequent I/O wait.
o It performs lots of computation or processing.
o It does little I/O.
o It keeps CPU busy most of the time.
Page 5
o When process switches from running state to waiting state. When process invokes I/O
operation it doesn’t need CPU. So, CPU becomes free and other process can be selected to
run.
o When process switches from running state to terminated state. When process completes its
execution, it doesn’t need CPU anymore and CPU becomes free.
o When process switches from running state to ready state. When process completes its
allowed time duration to use CPU, CPU is taken away from that process and allocated to some
other process.
o When process switches from waiting state to ready state. When I/O operation completes, or
an event, for which process is waiting, completes.
2) Preemptive scheduling
o Here one process is selected to execute. Then it is allowed to run only for some maximum
time duration. After that duration, another process is selected to execute (if any another
process is available).
o Very efficient but complex.
o Requires timer and clock interrupt.
o
Page 6