Operating System: No One Cares What Operating System You Run As Long As It Stays Up

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 48

OPERATING

SYSTEM
No one cares what operating
system you run as long as it
stays up.

“No one cares what operating system you run as long as it stays up”.
DISK SCHEDULING
ALGORITHM
Group Members are:
Aima Eman (071)
Faiqa Asghar (081)
Hafiza Laiba Asghar (084)
Hafiza Shamza Hanif (085)
Zumar Imran (121)
AGENDA
 INTRODUCTION​Of DISK SCHDUELING ALGORITHM
 TYPES OF DISK SCHDUELING ALGORITHM
 FCFS
 SSTF
 SCAN
 CLOOK​
Disk Scheduling Algorithm 4

DISK SCHEDULING ALGORITHM


What is Scheduling Algorithm?
Scheduling Algorithm schedule processes on the processor in an efficient and
effective manner. This scheduling is done by a Processor Scheduler. It
maximizes CPU utilization by increasing throughput.

Define Disk Scheduling Algorithm?


“Disk Scheduling Algorithm” is an algorithm that keeps and manages the input
output that arrives for the disk in a system. DSA is done by operating system to
schedule I/O requests arriving for the disk. Disk Scheduling is also known as I/O
scheduling.
WHY DISK SCHEDULING
ALGORITHM IS IMPORTANT?
 Multiple I/O requests may arrive by different processes
and only one I/O request can be served at a time by the
disk controller. Thus other I/O requests need to wait in
the waiting queue and need to be scheduled.
 Two or more request may be far from each other so can
result in greater disk arm movement.
 Hard drives are one of the slowest parts of the computer
system and thus need to be accessed in an efficient
manner.
There are many disk scheduling Algorithm but before
discussing them let’s have a quick look on some important
terms..
DIAGRAM OF DISK SCHEDULING ALGORITHM:

SPINDLE
Read/Write HEAD
TRACKS
PLATTER

CYLINDER
Read/Write HEAD

SECTORS

Read/Write HEAD
Presentation title 7
Disk Scheduling Algorithm
8

HOW TO CALCULATE THE SIZE OF


HARD DISK?

Let suppose there are 8 platters in hard disk drive. As each


platters has two surfaces so 16 surfaces will be there in hard
drive. Therefore, required R/W head will also be 16. Suppose,
there are 1,024 cylinders and 128 sectors in each track. The
sector size is 512 bytes. Then calculate disk size?
Formula:
Size of Hard Disk = Cylinders x Heads x Sectors x Sector-
size
Size of Hard Disk = 1024*16*128*512
Size of Hard Disk = 1,073,741,824
Disk Scheduling Algorithm 9

SEEK TIME
Seek Time:
When anything is read or written to a disc drive, the read/write head of the disc
moves to the right position. The actual physical positioning of the read/write head
of the disc is called seeking. The time the read/write head of the disc takes to move
from one disk to another is called the seek time.
Example:
Consider a hard disk of the concentric circle called tracks, and you want to fetch
some data, but the read/write head is currently on track 1.
But the user request data that is present on Track 4. In this case, the read/write head
will move to track 4 and the time it will take to reach track 4 is the seek time.
Formula:
Seek Time = (Time to cross 1 cylinder(track))*(No of cylinder(track)
crossed)
RATIONAL LATENCY
Rotational Latency: The time read/write head is required to move
from the current to the requested sector.
After reached to the required sector the head done and check
following things:
Settle Time: Settle time is the time required by the read/write head
to stop vibrating.
Command Processing Time: It is the time required by the disk
device to process the command and establish a connection between
the various components of the disk device to read/write data. It is
due to the internal circuitry.
Formula:
Rotational latency = (Angle by which disk is rotated) /
 (Angular Frequency)  
Disk Scheduling Algorithm
11

TRANSFER TIME
Transfer Time: Transfer time is the time to transfer the data. It is the
time interval between the start of the transfer and the completion of the
transfer. It depends on the rotating speed of the disk and number of
bytes to be transferred.
Types:
Internal Transfer Rate: It is defined as the time required to move data
between the disk surface and the hard disk cache.
External Transfer Rate: It is defined as the time required to move data
between the hard disk cache and the system.
Formula: T=b/rN
T= Transfer time, b= number of bytes to be transferred, N is no. of
bytes on a track and r is rotational speed
Disk Access Time:  We always access disk on the basis of their seek
time or rotational time or transfer time. So, the formula of DAT is..
Disk Access Time = Seek Time + Rotational Latency + Transfer
Time
FCFS IN DISK SCHEDULING
Presented By: Faiqa Asghar (2025110081)
Disk Scheduling Algorithm 13

FIRST COME FIRST SERVE (FCFS) 

 FCFS is the simplest disk scheduling algorithm. As the


name suggests, this algorithm entertains requests in the
order they arrive in the disk queue.
 The algorithm looks very fair and there is no starvation
(all requests are serviced sequentially) but generally, it
does not provide the fastest service.
Disk Scheduling Algorithm 14

EXAMPLE
Input:
Request sequence = {176, 79, 34, 60, 92, 11, 41, 114}
Initial head position = 50
Disk Scheduling Algorithm 15

SOLUTION
Seek Sequence is: {176, 79,34,60,92,11,41,114}

Therefore, the total seek count is calculated as: 

=(176-50)+(176-79)+(79-34)+(60-34)+(92-60)+(92-11)+(41-
11)+(114-41) = 510
Total number of seek operations = 510
Average waiting time: 510/8= 63.75
Disk Scheduling Algorithm 16
Disk Scheduling Algorithm 17
18

ADVANTAGES & DISADVANTAGES

ADVANTAGES DISADVANTAGES

• First Come First Serve is • This scheduling algorithm is


very simple and easy to non-preemptive, which
understand and means the process can’t be
implement. stopped in middle of
• In FCFS, each process execution.
eventually has a chance to • The throughput of FCFS is
execute, therefore there is not very efficient.
no starvation. • It is used in small systems
where I/O efficiency is not
important .
SSTF IN DISK SCHEDULING
Presented By: Aima Eman (2025110071)
Disk Scheduling Algorithm 20

SHORTEST SEEK TIME FIRST (SSTF)

 Shortest seek time first (SSTF) algorithm selects the


disk I/O request which requires the least disk arm
movement from its current position regardless of the
direction.
 It reduces the total seek time as compared to FCFS. It
allows the head to move to the closest track in the
service queue.
 Basic idea is the tracks which are closer to current disk
head position should be serviced first in order
to minimize the seek operations.
Presentation title 21

EXAMPLE
Request sequence : {176, 79, 34, 60, 92, 11, 41, 114} 
Initial head position = 50 
The following chart shows the sequence in which requested tracks are serviced
using SSTF=
Presentation title 22

SOLUTION
The order in which requests are served is:
{41,34,11,60,79,92,114,176}

Total seek count is calculated as: (50-41)+(41-34)+(34-


11)+(60-11)+(79-60)+(92-79)+(114-92)+(176-114)= 204
Total number of seek operations = 204
Average waiting time: 204/8= 25.5
Presentation title 23
26

ADVANTAGES & DISADVANTAGES

ADVANTAGES DISADVANTAGES

• The total seek time is • In SSTF there is an overhead of


reduced compared to First finding out the closest request.
Come First Serve. • Starvation may occur for
• SSTF improves and requests far from head.
increases throughput. • In SSTF high variance is
• Less average waiting time present in response time and
and response time in SSTF. waiting time.
• Frequent switching of the
Head’s direction slows the
algorithm.
SCAN IN DISK SCHEDULING
Presented By: Hafiza Laiba Asghar (2025110084)
Disk Scheduling Algorithm 28

SCAN/ELEVATOR ALGORITHM
 The scan is a disk scheduling algorithm that serves
requests generated by memory management unit.
 It is also called an elevator algorithm.
 In this algorithm read and write head has to move in
one direction and fulfill all the requests until we
move to the end of the disk.
 In this algorithm, the direction matters to serve
requests.
Presentation title 29

EXAMPLE
DIRECTION TOWARDS SMALLER VALUE:
Request sequence = {176, 79, 34, 60, 92, 11, 41, 114}
Initial head position = 50
Presentation title 30

SOLUTION
The order in which requests are served is:
{41,34,11,60,79,92,114,176}

Total seek count is calculated as:(50-41)+(41-34)+(34-11)+(11-


0)+(60-0)+(79-60)+(92-79)+(114-92)+(176-114)=226
Total number of seek operations = 226
Average waiting time: 226/8= 28.5
Presentation title 31

PROGRAM
Presentation title 36
37

ADVANTAGES & DISADVANTAGES

ADVANTAGES DISADVANTAGES

• It is simple, easy to • It causes long waiting


understand and time for the cylinders just
implement. visited by the head.
• It does not lead to • It causes the head to move
starvation. till the end of the disk
• It provides low variance even if there are no
in response time and requests to be serviced.
waiting time.
C-LOOK IN DISK SCHEDULING
Presented By: Zumar Imran (2025110121)
C-LOOK DISK SCHEDULING
ALGORITHM
 C-LOOK is an enhanced version of
both SCAN as well as LOOK disk scheduling
algorithms .

 In this algorithm, the head services requests only


in one direction(either left or right) until all the
requests in this direction are not serviced and then
jumps back to the farthest request on the other
direction and service the remaining requests.
EXAMPLE
Question:
Request sequence = {176, 79, 34, 60, 92, 11, 41, 114}
Initial head position = 50 
Direction = right (Moving from left to right) 
SOLUTION
Seek sequence is: {60,79,92,114,176,11,34,41}

Total seek count: (60 – 50) + (79 – 60) + (92 – 79) + (114 – 92)
+ (176 – 114) + (176 – 11) + (34 – 11) + (41 – 34) = 321

Total number of seek operations = 321


Average waiting time: 321/8= 40.125
Presentation title 42

PROGRAM
Presentation title 43
Presentation title 44
Presentation title 45
46

ADVANTAGES & DISADVANTAGES

ADVANTAGE DISADVANTAGE

• The waiting time is • There is an overhead of


decreased. finding the end requests.
• If there are no requests till
the end, it reverses the
head direction
immediately.
• Starvation does not occur.
Presentation title 47

COMPARISON
Algorithm Seek time
FCFS 510

SSTF 204

SCAN 226

C-LOOK 331
THANK YOU

You might also like