0% found this document useful (0 votes)
8 views15 pages

Operating Systems

The document discusses various scheduling algorithms for operating systems, focusing on Shortest Job First (SJF) and Round Robin (RR). It explains the advantages of SJF in reducing wait times for short processes and outlines the mechanics of RR, including time slices and context switching. Additionally, it introduces multilevel queues and multilevel feedback queues, detailing their structures and scheduling methods for managing process priorities and CPU time allocation.

Uploaded by

fareedasoomro41
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views15 pages

Operating Systems

The document discusses various scheduling algorithms for operating systems, focusing on Shortest Job First (SJF) and Round Robin (RR). It explains the advantages of SJF in reducing wait times for short processes and outlines the mechanics of RR, including time slices and context switching. Additionally, it introduces multilevel queues and multilevel feedback queues, detailing their structures and scheduling methods for managing process priorities and CPU time allocation.

Uploaded by

fareedasoomro41
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPS, PDF, TXT or read online on Scribd
You are on page 1/ 15

Operating

Systems
SJF is Optimal
 Logical Argument: Decrease in
the wait times for short processes
is much more than increase in the
wait times for long processes
P1 P2 P3
5 3 2

P3 P2 P1
2 3 5
Round Robin (RR)
 Each process gets a small unit
of CPU time, called time slice or
quantum, which is usually 10-
100 milliseconds. After this
time has elapsed, the process
is preempted and added to the
end of the ready queue.
Round Robin (RR)
 If there are n processes in the
ready queue, the time quantum
is q, and context switch time is
tcs, then no process waits more
than (n-1)(q+tcs) time units
 Used in time-sharing systems
where response time is an
important performance criteria
Round Robin (RR)

Performance
 q large  FCFS
 q small  q must be large with
respect to context
switch, otherwise
overhead is too high.
Round Robin Example
Process Burst Time
P1 53 — 33 — 13
P2 17
P3 68 — 48 — 28 —
8
P4 24 — 4
 The Gantt chart with quantum 20 is:
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3

0 20 37 57 77 97 117 121 134 154 162


Round Robin Example
Process Turnaround Time Waiting Time
P1 134 134 – 53 = 81
P2 37 37 – 17 = 20
P3 162 162 – 68 = 94
P4 121 121 – 24 = 97
 Average waiting time = 73
 Average waiting time for SJF = 38
 Typically, higher average turnaround
than SJF, but better response.
Quantum vs Context
Switch

Process Time = 10 Quantum Context


Switches

12 0

6 1

1 9
Turnaround Time vs
Quantum
Multilevel Queues
 Ready queue is partitioned into
separate queues:
- foreground (interactive)
- background (batch)
 Each queue has its own priority
and scheduling algorithm:
- foreground – RR
- background – FCFS
Multilevel Queues
 Scheduling must be done across
queues.
 Fixed priority scheduling; i.e.,
serve all from foreground then
from background.
 Time slice – each queue gets a
certain percentage of CPU time,
e.g., 80% to foreground in RR
and 20% to background in FCFS
Multilevel Queues
Multilevel Feedback Queues
 A process can move between the
various queues; aging can be
implemented this way.
 Multilevel-feedback-queue scheduler
defined by the following parameters:
 Number of queues
 Scheduling algorithms for each
queue
Multilevel Feedback Queues

 Method used to determine when to


upgrade a process
 Method used to determine when to
demote a process
 Method used to determine which
queue a process will enter when
that process needs service
Multilevel Feedback Queues

You might also like