0 ratings 0% found this document useful (0 votes) 6 views 25 pages OS Class - 5
The document discusses various CPU scheduling algorithms, including preemptive and non-preemptive scheduling, First Come First Serve (FCFS), Shortest Job First (SJF), and Round Robin. It outlines the advantages and disadvantages of each scheduling method, emphasizing factors like average wait time, response time, and implementation challenges. Additionally, it provides examples and calculations for average waiting time and turnaround time for different processes under these scheduling policies.
AI-enhanced title and description
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
Save OS Class_5 For Later Computer teacher 2025 )
Preemptive Schedul
Preemptive scheduling is used when a process switches from
running state to ready state or from waiting state to ready state.
The resources (mainly CPU cycles) are allocated to the process for
the limited amount of time and then is taken away, and the process
is again placed back in the ready queue if that process still has CPU
burst time remaining.
ann ble.
Rownel Robin
SRTE
Prin (PanayComputer teacher 2025 1
ap pers
<
5 on tog ( mone we)
® Non-preemptive Scheduling is used when a process terminates, or
a process switches from running to waiting state.
In this scheduling, once the resources (CPU cycles) is allocated to a
process, the process holds the CPU till it gets terminated or it
reaches a waiting state.
B In case of non-preemptive scheduling does not interrupt a process
running CPU in middle of the execution.
Instead, it waits till the process complete its CPU burst time and
then it can allocate the CPU to another process.
prcRadeave Mol my (4:1 nds)
R-@d)
Non:
reemptive ScheduComputer teacher 2025 1
_rtival Time: Time at which the process arrives in the ready queue.
_ Completion Time: Time at which process completes its execution.
_SyCTime Time required by a process for CPU execution.
ec:
__Jurf‘Around Time: Time Difference between completion time and
arrival time. Turn Around Time =|Completion Time — Arrival Time
_-wfsiting Time(W-7): Time Difference hetween turnaround time and
burst "7G Time =|Turn Around Time — Burst Time
i me
(30) RS) Pie To pum \
B30 Keom)Computer teacher 2025 1
First Come First Serve (FCFS) In FCFS Scheduling
The process which arrives first in the-ceady queue is firstly assigned
the.CPU. ea; |
case of a tie, process with smaller process id is executed first. Bl It
is alwaysTion-preemptive Jn nature.
Jobs are executed on first come, first serve basis.
tis a non-preemptive, préémptive scheduling algorithm.
Easy to understand and implement.
Its implementation is based on]FIFO hueue.
Poor in performance as average wait time is highComputer teacher 2025 1
Advantages-
Itis pe ale understand.
It can be easily implemented-csing queue data structure, _
Fl=so
It does not lead tapyation Disadvantages- PQs
It does not consider the priority or burst time of the processes. It
suffers from|Convoy effectli.e. processes with higher burst time
arrived before the processes with smaller burst time.Computer teacher 2025
Advantages-
It is simple and easy to understand.
It can be easily implemented using queue data structure.
It does not lead to starvation.
Disadvantages-
It does not consider the priority or burst time of the processes.
It suffers from convoy effect i.e. processes with higher burst time
arrived before the processes with smaller burst time._.\__ Computer teacher 2025 ]
o 2 Q Consider the following processes with by ime (CPU Execution time). Calculate the
averaged aerageenacond ting)>
Process id | Arrival time ‘Burst time/CPU execution time |e-T TAT | ws T
wT [TAT at | 0 2 Ufo
P2 1 3. o.14 '
3 2 3 jto [8 [3
i Pa 3 4 (ne
Tiii= [cea7] 5 4 6 | Zope | iolComputer teacher 2025 1
Consider the processes Pi, P2, P3, P4 given in the below table, arcives for execution
in the same order, with given Arrival Time and Burst Time.
PROCESS | ARRIVAL TIME | BURST TIME
Pl 0 8
2
1 4
PB. 2 9Computer teacher 2025 )
Pomme) PX
‘Me
Process which have the shortest burst time are scheduled first.
If two processes have the same bust time, then FCFS is used to break the tie.
pre-emptlye scheduling algorithm. @ Best approach to
SV To Implement in Batch systems where required CPU time is known in advance.
__~mpossible to implement in interactive systems where required CPU time is not
known.
‘The processer should know i
Prasemnptive mode of Shortest Job First is called as Shortest Rem:
(ere)
eu) = E
€ Now. Pocomehy
advance how much ti
1e process will take.
ing Time FirstComputer teacher 2025 )
Advantages-
or optimal and guarantees the minimum average waiting time.
_bpitovides a standard for other algorithms since no other algorithm
‘performs better than it.
Disadvantages-
It can not be implemented practically since burst time of the processes can
not be known in advance.
It leads to starvation for processes with larger burst time.
Priorities can not be set for the processes. Processes with larger burst
time have poor response time. 4Computer teacher 2025 )
Advantages-
SRTF is optimal and guarantees the minimum average wai
ig time.
lt provides a standard for other algorithms since no other algorithm
performs better than it.
Disadvantages-
Blt can not be implemented practically since burst time of the processes
can not be known in advance.
Bit leads to starvation for processes with larger burst time.
© Priorities can not be set for the processes.
Bi Processes with larger burst time have poor response timeComputer teacher 2025 1
Example-1:
Consider the set of 5 provesses whose arrival time and burst time are given below-
Process 1d {-T} Arrival time |74] »T\Burst time
Pit 3 7y3[ 1 WO
Bm [IG isn 4
Bn | 4-qsl|s| 2 —
pe 1G 0 [6[O][ «6
ps fT] 2-7 3 @ |
Iss
evyr[ry re |
og aT TAT Yo/es gComputer teacher 2025 1
‘Consider the set of 5 processes whose arrival time and burst time are given below-
Process Id Arrival time Burst time
Pl 3 1
PD U 4
BB 4 a
Pd 0 6
PS 2 3
Ifthe CPU scheduling policy is SIF pre-emptive calculate the average waiting time and
average tumaround time.Computer teacher 2025 1
Consider the set of 3 processes whose arrival time and burst time are given below-
Process Id_| Arrival time | Burst time
PI 0 9
PR 1 4
PS 2 9
Ifthe CPU scheduling policy is SRTF, calculate the average waiting time and average
tum around time.Computer teacher 2025 1
Round Robin Sched:
ing
CPU is assigned to the process on the basis of FCFS for a fixed
amount of time.
8 This fixed amount of time is called as time quantum or time
slice.
After the time quantum expires, the running process is
preempted and sent to the ready queue.
Then, the processor is assigned to the next arrived process.
is always preemptive in natureComputer teacher 2025
completion
Round Robin SchedulingComputer teacher 2025 )
Advantages-
It gives the best performance in terms of average response time.
It is best suited for time sharing system, client server architecture
and interactive system.Computer teacher 2025 )
Disadvantages-
It leads to starvation for processes with larger burst time as they
have to repeat the cycle many times.
Its performance heavily depends on time quantum.
Priorities can not be set for the processes.Computer teacher 2025
With decreasing value of time quantum,
f® Number of context switch increases
Response time decreases
hances of starvation decreases
response time.Computer teacher 2025 )
With increasing value of time quantum,
@ Number of context switch decreases
@ Response time increases
@ Chances of starvation increases
Thus, higher value of time quantum is better in terms of number of context
switch.Computer teacher 2025 1
With increasing value of time quantum, Round Robin Scheduling tends to
become FCFS Scheduling.
(@ When time quantum tends to infinity, Round Robin Scheduling becomes
FCFS Scheduling.
@ The performance of Round Robin scheduling heavily depends on the value of
time quantum.
{The value of time quantum should be such that it is neither too big nor too
small.Computer teacher 2025 )
Example-01;
‘Consider the set of 5 processes whose arrival time and burst ime are given below
Process Id Arrival time Burst time
PL 0 Si
PR 1 3
P3 4 1
Pd 3 2
PS 4 3Computer teacher 2025APP FEATURES
Current Affairs
5
z
Daily Quizzes Subject
Poe ad
e ¢
Addale4i7) APP
‘Magazines Power Capsule
=F
Notes & ArticlesPOOL
HOGS