Disks and Disk Scheduling
description
Transcript of Disks and Disk Scheduling
![Page 1: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/1.jpg)
Disks and Disk Scheduling
Steve Muckle
Monday, March 31st 2003
15-412 Spring 2003
![Page 2: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/2.jpg)
Carnegie Mellon University 2
Overview
Project Discussion Anatomy of a Hard Drive Common Disk Scheduling Algorithms Freeblock Scheduling
![Page 3: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/3.jpg)
Carnegie Mellon University 3
Project Discussion (3)
Project 3 is over! War stories? Sage advice?
Sign ups for interviews will begin soon Watch bboard
![Page 4: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/4.jpg)
Carnegie Mellon University 4
Project Discussion (4)
File System project out today Lots of code Planning will save you pain and suffering Read it tonight (this afternoon even!)
![Page 5: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/5.jpg)
Carnegie Mellon University 5
Anatomy of a Hard Drive
On the outside, a hard drive looks like this
Taken from “How Hard Disks Work”http://computer.howstuffworks.com/hard-disk2.htm
![Page 6: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/6.jpg)
Carnegie Mellon University 6
Anatomy of a Hard Drive
If we take the cover off, we see that there actually is a “hard disk” inside
Taken from “How Hard Disks Work”http://computer.howstuffworks.com/hard-disk2.htm
![Page 7: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/7.jpg)
Carnegie Mellon University 7
Anatomy of a Hard Drive
A hard drive usually contains multiple disks, called platters
These spin at thousands ofRPM (5400,7200, etc)
Taken from “How Hard Disks Work”http://computer.howstuffworks.com/hard-disk2.htm
![Page 8: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/8.jpg)
Carnegie Mellon University 8
Anatomy of a Hard Drive
Information is written to and read from the platters by the read/write heads on the disk arm
Taken from “How Hard Disks Work”http://computer.howstuffworks.com/hard-disk2.htm
![Page 9: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/9.jpg)
Carnegie Mellon University 9
Anatomy of a Hard Drive
Both sides of each platter store information
Each side ofa platter iscalled asurface
Each surfacehas its ownread/write head
Taken from “How Hard Disks Work”http://computer.howstuffworks.com/hard-disk2.htm
![Page 10: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/10.jpg)
Carnegie Mellon University 10
Anatomy of a Hard Drive
How are the surfaces organized?
a surface
![Page 11: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/11.jpg)
Carnegie Mellon University 11
Anatomy of a Hard Drive
Each surface is divided by concentric circles, creating tracks
tracks
![Page 12: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/12.jpg)
Carnegie Mellon University 12
Anatomy of a Hard Drive
The matching tracks on all surfaces are collectively called a cylinder
![Page 13: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/13.jpg)
Carnegie Mellon University 13
Anatomy of a Hard Drive
These tracks are further divided into sectors
![Page 14: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/14.jpg)
Carnegie Mellon University 14
Anatomy of a Hard Drive
A sector is the smallestunit of data transfer toor from the disk
Most modern harddrives have 512 bytesectors
a sector
![Page 15: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/15.jpg)
Carnegie Mellon University 15
Anatomy of a Hard Drive
Does this mean that sectorson the outside of a surfaceare larger than those onthe inside?
Modern hard drivesfix this with zoned-bit recording
![Page 16: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/16.jpg)
Carnegie Mellon University 16
Anatomy of a Hard Drive
Why don’t we read in a sector from the disk
read/write head
desired sector
disk rotatescounter-clockwise
![Page 17: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/17.jpg)
Carnegie Mellon University 17
Anatomy of a Hard Drive
We need to do two things to transfer a sector
1. Move the read/write head to the appropriate track (seek)
2. Wait until the desired sector spins around
![Page 18: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/18.jpg)
Carnegie Mellon University 18
Anatomy of a Hard Drive
Why don’t we read in a sector from the disk
read/write head
![Page 19: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/19.jpg)
Carnegie Mellon University 19
Anatomy of a Hard Drive
Why don’t we read in a sector from the disk
read/write head
![Page 20: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/20.jpg)
Carnegie Mellon University 20
Anatomy of a Hard Drive
Why don’t we read in a sector from the disk
read/write head
![Page 21: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/21.jpg)
Carnegie Mellon University 21
Anatomy of a Hard Drive
Why don’t we read in a sector from the disk
read/write head
![Page 22: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/22.jpg)
Carnegie Mellon University 22
Anatomy of a Hard Drive
Why don’t we read in a sector from the disk
read/write head
![Page 23: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/23.jpg)
Carnegie Mellon University 23
Anatomy of a Hard Drive
Why don’t we read in a sector from the disk
read/write head
![Page 24: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/24.jpg)
Carnegie Mellon University 24
Anatomy of a Hard Drive
Why don’t we read in a sector from the disk
read/write head
![Page 25: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/25.jpg)
Carnegie Mellon University 25
Anatomy of a Hard Drive
Why don’t we read in a sector from the disk
read/write head
![Page 26: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/26.jpg)
Carnegie Mellon University 26
Anatomy of a Hard Drive
Why don’t we read in a sector from the disk
read/write head
![Page 27: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/27.jpg)
Carnegie Mellon University 27
Anatomy of a Hard Drive
On average, we will have to move the read/write head over half the tracks
The time to do this is the average seek time, and is ~10ms
We will also have to wait half a rotation The time to do this is rotational latency, and
on a 5400 rpm drive is ~5.5ms
![Page 28: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/28.jpg)
Carnegie Mellon University 28
Anatomy of a Hard Drive
There are two other things that determine overall disk access time- settle time, the time to stabilize the read/write head after a seek- command overhead, the time for the disk to process a command and start doing something
They are both fairly minor compared to seek time and rotational latency
![Page 29: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/29.jpg)
Carnegie Mellon University 29
Anatomy of a Hard Drive
Total drive random access time is on the order of 15 to 20 milliseconds
Oh man, disks are slow
What can we, as operating system programmers, do about this?
![Page 30: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/30.jpg)
Carnegie Mellon University 30
Disk Scheduling Algorithms
The goal of a disk scheduling algorithm is to be nice to the disk
We can help the disk by giving it requests that are located close to each other on the disk
This minimizes seek time, and possibly rotational latency
There exist a variety of ways to do this
![Page 31: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/31.jpg)
Carnegie Mellon University 31
First Come First Served (FCFS)
Requests are sent to the disk as they are generated by the OS
Trivial to implement Fair – no request will be starved because of
its location on the disk Provides an unacceptably high mean
response time …except for project four!
![Page 32: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/32.jpg)
Carnegie Mellon University 32
Shortest Seek Time First (SSTF)
Always send the request with the shortest seek time from current head position
Generates very fast response time Intolerable response time variance, however Why?
![Page 33: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/33.jpg)
Carnegie Mellon University 33
SCAN
Send requests in ascending cylinders When last cylinder is reached, reverse the
scan Mean response time is worse than SSTF, but
better than FCFS Better response time variance than SSTF Unfair – why?
![Page 34: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/34.jpg)
Carnegie Mellon University 34
LOOK
Just like SCAN – sweep back and forth through cylinders
If there are no more requests in our current direction we reverse course
Improves mean response time, variance Still unfair though
![Page 35: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/35.jpg)
Carnegie Mellon University 35
CSCAN
Send requests in ascending (or descending) cylinders
When the last cylinder is reached, seek all the way back to the beginning
Long seek is amortized across all accesses Variance is improved Fair Still missing something though…
![Page 36: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/36.jpg)
Carnegie Mellon University 36
C-LOOK
CSCAN + LOOK Only scan in one direction, as in CSCAN If there are no more requests in current
direction reverse course Very popular
![Page 37: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/37.jpg)
Carnegie Mellon University 37
Shortest Positioning Time First (SPTF)
Similar to Shortest Seek Time First Always select request with shortest total
positioning time (rotational latency + seek time)
More accurate greedy algorithm than SSTF Same starvation problems
![Page 38: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/38.jpg)
Carnegie Mellon University 38
Weighted Shortest Positioning Time First (WSPTF)
SPTF, but we age requests to prevent starvation
Aging policy is very flexible Excellent performance Why don’t we use this?
![Page 39: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/39.jpg)
Carnegie Mellon University 39
Freeblock Scheduling
Research going on right here at CMU Something I am involved in this semester
Who would like some free bandwidth while their disk is busy?
![Page 40: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/40.jpg)
Carnegie Mellon University 40
Freeblock Scheduling
We have settled on a disk scheduling routine (probably C-LOOK)
We have a queue of disk requests Let’s take a closer look at a pair of possible
disk requests
![Page 41: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/41.jpg)
Carnegie Mellon University 41
Freeblock Scheduling
There are two requests at the disk
read/write head
first request
second request
![Page 42: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/42.jpg)
Carnegie Mellon University 42
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 43: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/43.jpg)
Carnegie Mellon University 43
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 44: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/44.jpg)
Carnegie Mellon University 44
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 45: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/45.jpg)
Carnegie Mellon University 45
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 46: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/46.jpg)
Carnegie Mellon University 46
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 47: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/47.jpg)
Carnegie Mellon University 47
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 48: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/48.jpg)
Carnegie Mellon University 48
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 49: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/49.jpg)
Carnegie Mellon University 49
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 50: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/50.jpg)
Carnegie Mellon University 50
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 51: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/51.jpg)
Carnegie Mellon University 51
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 52: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/52.jpg)
Carnegie Mellon University 52
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 53: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/53.jpg)
Carnegie Mellon University 53
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 54: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/54.jpg)
Carnegie Mellon University 54
Freeblock Scheduling
There are two requests at the disk
read/write head
![Page 55: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/55.jpg)
Carnegie Mellon University 55
Freeblock Scheduling
As in SPTF scheduling, we must know the EXACT state of the disk
We need to be able to predict how much rotational latency we have to work with
Enemies of freeblock scheduling:disk prefetchinginternal disk cache hitsunexpected disk activity (recalibration, etc)disk-reordered requests
![Page 56: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/56.jpg)
Carnegie Mellon University 56
Freeblock Scheduling
Results include 3.1MB/sec of free bandwidth This free bandwidth is best suited to
applications with loose time constraints Some sample applications:
- backup applications- disk array scrubbing- cache cleaning (perhaps…)
![Page 57: Disks and Disk Scheduling](https://reader036.fdocuments.in/reader036/viewer/2022062408/5681377a550346895d9f1232/html5/thumbnails/57.jpg)
Carnegie Mellon University 57
Read the project 4 handout!