OS Unit 3
OS Unit 3
CE0418
Unit-3
Disk Scheduling
Prof. Indr Jeet Rajput
Assistant Professor CE & IT
1
Definitions
▪ Seek time: The time to move the arm to the proper cylinder.
▪ Rotational delay: The time for the proper sector to rotate under
the head.
2
Disk Arm Scheduling Algorithm
▪ Various types of disk arm scheduling algorithms are available to
decrease mean seek time.
1. FCFS (First come first serve)
2. SSTF (Shorted seek time first)
3. SCAN
4. C-SCAN
5. LOOK (Elevator)
6. C-LOOK
3
Example for Disk Arm Scheduling Algorithm
▪ Consider an imaginary disk with 51 cylinders. A request comes in to read a
block on cylinder 11. While the seek to cylinder 11 is in progress, new requests
come in for cylinders 1, 36, 16, 34, 9, and 12, in that order.
▪ Starting from the current head position, what is the total distance (in cylinders)
that the disk arm moves to satisfy all the pending requests, for each of the
following disk scheduling Algorithms?
4
FCFS (First come first serve)
• 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.
Disadvantages:
• The scheme does not optimize the seek time.
• The request may come from different processes therefore there is the possibility
of inappropriate movement of the head.
5
FCFS (First come first serve)
▪ Here requests are served in the order of their arrival.
0 1 9 12 16 34 36 50
11 1,
36,
1 16,
36 34,
9,
16 12
34
9
12
6
SSTF (Shortest seek time first)
• 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.
Disadvantages:
• It may cause starvation for some requests.
• Switching direction on the frequent basis slows the working of algorithm.
• It is not the most optimal algorithm.
7
SSTF (Shortest seek time first)
▪ We can minimize the disk movement by serving the request
closest to the current position of the head.
0 1 9 12 16 34 36 50
11 1,
36,
12 16,
9 34,
16 9,
12
1
34
36
9
LOOK (Elevator)
0 1 9 12 16 34 36 50
11 1,
36,
12
16,
16 34,
34 9,
12
36
9
1
10
C-LOOK
▪ Keep moving in the same direction until there are no more
outstanding requests pending in that direction, then algorithm
switches direction.
▪ When switching occurs the arm goes to the lowest numbered
cylinder with pending requests and from there it continues
moving in upward direction again.
11
C-LOOK
0 1 9 12 16 34 36 50
11 1,
36,
12
16,
16 34,
34 9,
12
36
1
9
12
SCAN
▪ From the current position disk arm starts in up direction and
moves towards the end, serving all the pending requests until
end.
▪ At that end arm direction is reversed (down) and moves towards
the other end serving the pending requests on the way.
13
SCAN
0 1 9 12 16 34 36 50
11 1,
36,
12
16,
16 34,
34 9,
12
36
9 50
1
14
CSCAN
▪ From the current position disk arm starts in up direction and
moves towards the end, serving request until end.
▪ At the end the arm direction is reversed (down), and arm
directly goes to other end and again continues moving in
upward direction.
15
CSCAN
0 1 9 12 16 34 36 50
11 1,
12 36,
16,
16 34,
34 9,
12
36
0 50
1
9
▪ Disk movement will be 11, 12, 16, 34, 36, 50, 0, 1,9.
▪ Total cylinder movement: (12-11) + (16-12) + (34-16) +(36-34)
+(50-36) + (50-0) + (1-0)+ (9-1) = 98
16
Disk Caches
• A disk cache (cache memory) is a temporary holding area in the hard disk or
random access memory (RAM) where the computer stores information that used
repeatedly.
• The computer can use it to speed up the process of storing and accessing the
information much more quickly from the disk cache than if the information
stored in the usual place (which might be on a disk or in a part of the computer’s
memory that takes longer to access).
• The term disk cache can also refer to a disk buffer and cache buffer.
• The basic idea behind a disk cache is that working with information stored in
memory (RAM) is much faster than working with information stored on disk.
• A disk cache is a software utility that works by reserving a section of memory
where it keeps a copy of information that previously read from your disks.
• The next time your computer needs that same information, the data can be
accessed directly from the cache, bypassing the slower disk.
• However, if the CPU (central processing unit, the chip that runs the computer)
needs data that is not in the disk cache, then it has to go to the disk and get it, in
which case there is no advantage to having part of your memory set aside for the
disk cache.
17
Disk Caches
• A
18