You are on page 1of 20

ABV-Indian Institute of Information Technology and Management

Gwalior

Lecture : 2 - 3
====================================================================================================

Process Management
(IMIT-2205)
====================================================================================================

Instructor – Dr. Sunil Kumar 
Office – 206, F‐Block (V), Tel No – 0751‐2449710 (O), Email  ‐ snk@iiitm.ac.in
Mob   ‐ 8472842090 
Summary of Last Class
 Role of Operating System (OS).

 Difficulties faces by an user for accessing a computer without OS.

 Steps involved in executing a program.

 Operating System as a Resource Manager.


Operating System as a Resource Manager
 As we have discuses that an operating system basically manages
resources of a computer.

 Major resources of a computer are :


 CPU
 Memory (RAM, Hard disk, and so on)
 I/O Devices

 Why do we need to manage above resources?


 Limited resources and their computing power.
 Users like to run multiple programs without any delay.
CPU / Process Management
 Let us take an example to understand the need of process management:
 Example-1

Process Time of execution
𝑃 10 units
𝑤 𝑃 𝑃 𝑃 𝑃 𝑃
𝑃 5 units
A 10 B 5 15 8 2
𝑃 15 units
𝑃 8 units
𝑃 2 units Waiting time

𝑡 𝑡 Waiting time = 𝑡 𝑡

Turnaround time = 𝑡 𝑡
𝑡 𝑡 𝑡

Turnaround time for process 𝑃


CPU / Process Management
 Let us take an example to understand the need of process management:
 Example-1
Process Time of execution
𝑃 10 units
𝑤 5 𝑃 𝑃 𝑃 𝑃 𝑃
𝑃 5 units
A 10 B 5 15 8 2
𝑃 15 units
𝑃 8 units 𝑤
𝑃 2 units
𝑤

𝑤
118
𝑡 23.6
5
𝑤
Average waiting time
Process Management
 Example-1
Process Time of execution
𝑃 10 units
𝑤 5 𝑃 𝑃 𝑃 𝑃 𝑃
𝑃 5 units
A 10 B 5 15 8 2
𝑃 15 units
𝑃 8 units
𝑃 2 units

The CPU scheduling approach that we have demonstrated here is based on


the order in which processes were arrived.
 Hence, this approach is also known as “First-Come, First-Served (FCFS)
Scheduling” algorithm.
 Example-2 CPU / Process Management
 Let us assume a slightly different approach opted by OS to schedule the
CPU for the execution of processes.
 Basis for execution of processes : Programs which take less time will be
executed first, and then second shorter programs, and so on.

Process Time of execution
𝑃 10 units 𝑃 𝑃 𝑃 𝑃 𝑃

𝑃 5 units 2 5 8 10 15
𝑃 15 units
𝑃 8 units
𝑃 2 units
 Example-2 CPU / Process Management
Waiting time
𝑤𝑝 0 𝑃 𝑃 𝑃 𝑃 𝑃

𝑤𝑝 2 2 5 8 10 15
𝑤𝑝 7
𝑤𝑝 15 54
𝑤𝑝 30 𝑡 10.8
5

 Average waiting time is drastically reduced by simply changing the order


of execution.
 A more better algorithm can also be opted for better utilization of CPU.
 From the above two examples, it is clear that if a CPU schedule algorithm
is efficient, the programs can be executed in a much faster rate.
Key Points Involved in CPU Process
 Process
 CPU burst and I/O burst
 Process states
 CPU-bound and I/O bound
 Process control block
 Context switching
 CPU Scheduling
 …..so on.
Process
 Process : a program under execution is called a process.
 Whenever a program is there in the secondary device, till then it is just a
program.
 Passive state : a program not under execution.
 However, once a program is loaded into main memory for execution, we
call it a process.
We also say that the program is an active state.
CPU burst and I/O burst
 CPU burst : It is the CPU time used by a process or a sub-process for its
execution
 I/O burst : It is the time used by I/O devices to feed the necessary inputs
to the process.

Process

CPU burst I/O burst CPU burst CPU burst


CPU burst and I/O burst
 Single programming/tasking based OS: For this system, CPU remains in
idle state for time when a process is in I/O state. Example – MS-DOS
(DOS-based OS).
 Advantage : require low memory
 Disadvantage : execute a single program at a time.

Multiprogramming (Multi-tasking) based OS: CPU is allocated to some


other process when the current process goes to I/O state.
 Multiple tasks were executed on CPU in a time-sharing based approach.
Process

CPU burst I/O burst CPU burst CPU burst


Single-User Vs. Multi-User based OS
 Single-user multi-taking (SUMT) based OS: An operating system that
allows a single user to perform multiple tasks at a time on a system is called
SUMT-based OS. Example : Microsoft Windows, Ubuntu, and so on
Single-User Vs. Multi-User based OS
 Multi-user multi-taking (MUMT) based OS: An operating system that
allows multiple users to execute their tasks is called MUMT-based OS.
Example : Microsoft Windows, Ubuntu, and so on

Figure-1 : MUMT based OS.

Thorn, Tine, et al. A distributed, value-oriented XML Store. Diss. Master’s thesis, IT University of Copenhagen, 2002.
Process State
Process states : It refers to the stages through which a process passes
before its final execution (termination).
 Moreover, it mainly indicating life cycle of a process.
The process is being created Instructions are being executed.

TERMINATED
NEW STATE
STATE
READY RUNNING
STATE STATE The process has finished execution

The process is waiting to be


assigned to a processor.
WAITING
The process is waiting for some event
STATE
to occur (such as an I/O completion or
reception of a signal).
CPU-bound and I/O bound Processes
 CPU-bound process : Most of the time CPU is busy in doing computations.
CPU Time I/O CPU Time CPU Time CPU Time I/O CPU Time

Less frequently, I/O request is generated

 I/O-bound process : Spend more time in doing I/O operations.


CPU  I/O CPU I/O CPU I/O CPU

I/O request is more frequently generated.


Process Control Block
 Each process is represented in the Process Control Block
operating system by a process control Process Number
block (PCB)—also called a task control Process State
block.
Program Counter
 The PCB contains many pieces of
information associated with a specific Registers
process. Memory limits

CPU Scheduling Information


Context Switch (CS)
 Refers to CPU switching from one process (current/old process) to a new
process.
 Context switch may occur due to an interrupt (generally programs that need
to be executed without any delay) or I/O waiting.
 When the CS occur :
 CPU has to save the state of current (old) process, and it has to load the
saved state of the new process.
 The information pertaining to a CS of a process (such as registers, the
process state, memory management information, and so on) is stored in the
process control block (PCB).
 While doing context switching, CPU does not do any useful work, and so
the context-switch time is purely overhead.
Text Books and Reference Books for OS

 Text Books
1. Silberschatz, A., Galvin, P.B. and Gagne, G., Operating System Concepts, John Wiley
(2004) 7th ed.
2. Stallings, Willam, Operating Systems Internals and Design Principles, Prentice Hall
(2009) 6th ed.

 Reference Books
1. Dhamdhere, D.M., Operating Systems: A Concept Based Approach, Mc Graw Hill
(2008) 2nd ed.
2. Flynn, I.M. and McHoes, A.M., Understanding Operating Systems, Thomson (2007).
Thank You!

You might also like