Download - Disks Mar. 21, 2005
![Page 1: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/1.jpg)
15-410, S’101
DisksMarch 15, 2010
Dave Eckhardt & Garth GibsonDave Eckhardt & Garth Gibson
Brian Railing & Steve MuckleBrian Railing & Steve Muckle
Contributions fromContributions from Eno Thereska, Rahul IyerEno Thereska, Rahul Iyer 15-21315-213 ““How Stuff Works” web siteHow Stuff Works” web site
L22_Disks1
15-410“...What goes around comes around...”
![Page 2: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/2.jpg)
15-410, S’102
Overview
Anatomy of a Hard DriveAnatomy of a Hard Drive
Common Disk Scheduling AlgorithmsCommon Disk Scheduling Algorithms
![Page 3: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/3.jpg)
15-410, S’103
Anatomy of a Hard Drive
On the outside, a hard On the outside, a hard drive looks like thisdrive looks like this
Taken from “How Hard Disks Work”http://computer.howstuffworks.com/hard-disk2.htm
![Page 4: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/4.jpg)
15-410, S’104
Anatomy of a Hard Drive
If we take the cover off, If we take the cover off, we see that there we see that there actually is a “hard actually is a “hard disk” insidedisk” inside
Taken from “How Hard Disks Work”http://computer.howstuffworks.com/hard-disk2.htm
![Page 5: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/5.jpg)
15-410, S’105
Anatomy of a Hard Drive
A hard drive usually A hard drive usually contains multiple contains multiple disks, called disks, called plattersplatters
These spin at These spin at thousands ofthousands ofRPM (5400,RPM (5400,7200, etc)7200, etc)
Taken from “How Hard Disks Work”http://computer.howstuffworks.com/hard-disk2.htm
![Page 6: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/6.jpg)
15-410, S’106
Anatomy of a Hard Drive
Information is written to Information is written to and read from the and read from the platters by the platters by the read/write headsread/write heads on on the end of the the end of the disk disk armarm
Taken from “How Hard Disks Work”http://computer.howstuffworks.com/hard-disk2.htm
![Page 7: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/7.jpg)
15-410, S’107
Anatomy of a Hard Drive
Both sides of each Both sides of each platter store platter store informationinformation
Each side ofEach side ofa platter isa platter iscalled acalled asurfacesurface
Each surfaceEach surfacehas its ownhas its ownread/write headread/write head
Taken from “How Hard Disks Work”http://computer.howstuffworks.com/hard-disk2.htm
![Page 8: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/8.jpg)
15-410, S’108
Anatomy of a Hard DriveThe arm is moved by a The arm is moved by a
voice coil actuatorvoice coil actuator
Slow, as computers goSlow, as computers go Acceleration timeAcceleration time Travel timeTravel time
Taken from “Hard Disk Drives”http://www.pcguide.com/ref/hdd
Oklobdzija, Comp. Eng. Handbook, 2002
![Page 9: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/9.jpg)
15-410, S’109
Anatomy of a Hard Drive
How are the surfaces organized?How are the surfaces organized?
a surface
![Page 10: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/10.jpg)
15-410, S’1010
Anatomy of a Hard Drive
Each surface is divided by concentric circles, creating Each surface is divided by concentric circles, creating trackstracks
tracks
![Page 11: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/11.jpg)
15-410, S’1011
Anatomy of a Hard Drive
These tracks are further divided into These tracks are further divided into sectorssectors
![Page 12: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/12.jpg)
15-410, S’1012
Anatomy of a Hard Drive
These tracks are further These tracks are further divided into divided into sectorssectors
A sector is the smallestA sector is the smallestunit of data transfer tounit of data transfer toor from the diskor from the disk 512 bytes – traditional
disks 2048 bytes – CD-ROMs 4096 bytes – 2010 disks
(pretend to be 512!)
Gee, those outer sectors Gee, those outer sectors look bigger...?look bigger...?
a sector
![Page 13: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/13.jpg)
15-410, S’1013
Anatomy of a Hard Drive, Really
Modern hard drives use Modern hard drives use zoned bit recordingzoned bit recording Disk has tables to map
track# to #sectors Sectors are all roughly the
same linear length
Taken from “Reference Guide – Hard Disk Drives”http://www.storagereview.com/map/lm.cgi/zone
![Page 14: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/14.jpg)
15-410, S’1014
Anatomy of a Hard Drive
Let's read in a sector from the diskLet's read in a sector from the disk
read/write head
desired sector
disk rotatescounter-clockwise
![Page 15: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/15.jpg)
15-410, S’1015
Anatomy of a Hard Drive
We need to do two things to transfer a sectorWe need to do two things to transfer a sector
1. Move the read/write head to the appropriate track 1. Move the read/write head to the appropriate track (“seek time”)(“seek time”)
2. Wait until the desired sector spins around 2. Wait until the desired sector spins around (“rotational delay”/“rotational latency”)(“rotational delay”/“rotational latency”)
ObserveObserve Average seeks are 2 – 10 msec Disk rotates 5,400...15,000 rpm, delay 11...4 msec Rotation dominates short seeks, matches average seeks We could say “seek delay” or “rotational time” - but experts
usually don't (now you know how to sound like an expert)
![Page 16: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/16.jpg)
15-410, S’1016
Anatomy of a Hard Drive
Let's read in a sector from the diskLet's read in a sector from the disk
read/write head
![Page 17: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/17.jpg)
15-410, S’1017
Anatomy of a Hard Drive
Let's read in a sector from the diskLet's read in a sector from the disk
read/write head
![Page 18: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/18.jpg)
15-410, S’1018
Anatomy of a Hard Drive
Let's read in a sector from the diskLet's read in a sector from the disk
read/write head
![Page 19: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/19.jpg)
15-410, S’1019
Anatomy of a Hard Drive
Let's read in a sector from the diskLet's read in a sector from the disk
read/write head
![Page 20: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/20.jpg)
15-410, S’1020
Anatomy of a Hard Drive
Let's read in a sector from the diskLet's read in a sector from the disk
read/write head
![Page 21: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/21.jpg)
15-410, S’1021
Anatomy of a Hard Drive
Let's read in a sector from the diskLet's read in a sector from the disk
read/write head
![Page 22: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/22.jpg)
15-410, S’1022
Anatomy of a Hard Drive
Let's read in a sector from the diskLet's read in a sector from the disk
read/write head
![Page 23: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/23.jpg)
15-410, S’1023
Anatomy of a Hard Drive
Let's read in a sector from the diskLet's read in a sector from the disk
read/write head
![Page 24: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/24.jpg)
15-410, S’1024
Anatomy of a Hard Drive
Let's read in a sector from the diskLet's read in a sector from the disk
read/write head
![Page 25: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/25.jpg)
15-410, S’1025
Anatomy of a “Sector”
Finding a sector involves real workFinding a sector involves real workCorrect track; check sector header for number
After sector is read, compare data to checksumAfter sector is read, compare data to checksum
011010100011000101010101 0001 0101011101..010 0010 010101
trainingservosector numbersector datachecksum
(ECC)
0000000010001101111111100 0001 01011011100010 010110
read/write head
![Page 26: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/26.jpg)
15-410, S’1026
Disk Cylinder
Matching tracks across surfaces are collectively called Matching tracks across surfaces are collectively called a a cylindercylinder
![Page 27: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/27.jpg)
15-410, S’1027
Disk Cylinder
Matching tracks form a cylinder.Matching tracks form a cylinder.
surface 0
surface 1surface 2
surface 3surface 4
surface 5
cylinder k
spindle
platter 0
platter 1
platter 2
![Page 28: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/28.jpg)
15-410, S’1028
Access Within A Cylinder is FasterHeads share one single armHeads share one single arm
All heads always on same cylinder
Switching heads is “cheap”Switching heads is “cheap” Deactivate head I, activate J Read a few sector headers to
fine-tune arm position for J's track
Optimal transfer rate?Optimal transfer rate?1.Transfer all sectors on a track2.Transfer all tracks on a cylinder3.Then move the arm
arm
read/write heads move in unison
from cylinder to cylinder
spindle
![Page 29: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/29.jpg)
15-410, S’1029
Some Disk Specs (2009)Big is 2TB capacity, Cool is 1-2 W, Fast is 3.5 ms seeksBig is 2TB capacity, Cool is 1-2 W, Fast is 3.5 ms seeks
![Page 30: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/30.jpg)
15-410, S’1030
Some Disk Specs (2009)Big $330 ($.16/Big $330 ($.16/GBGB), Cool $85 ($.17/), Cool $85 ($.17/GBGB), Fast $670 ($1.12/), Fast $670 ($1.12/GBGB))
![Page 31: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/31.jpg)
15-410, S’1031
Some Disk Specs (2009)Price lead is $.07/GB (smaller, slower, hotter, failure Price lead is $.07/GB (smaller, slower, hotter, failure
prone)prone)
![Page 32: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/32.jpg)
15-410, S’1032
Access Time
On average, we will have to move the read/write head On average, we will have to move the read/write head over one third of the tracksover one third of the tracks The time to do this is the “average seek time”, and is ~10ms
for a 5400 rpm disk
We will also must wait half a rotation, on averageWe will also must wait half a rotation, on average The time to do this is average rotational delay, and on a
5400 rpm drive is ~5.5ms
Seagate 7200.7, a 2005-era 7200 RPM SATA driveSeagate 7200.7, a 2005-era 7200 RPM SATA drive Average seek time 8.5 ms Average rotational delay 4.16 ms
![Page 33: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/33.jpg)
15-410, S’1033
Access Time
Other factors influence overall disk access timeOther factors influence 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
Minor compared to seek time and rotational delayMinor compared to seek time and rotational delay
![Page 34: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/34.jpg)
15-410, S’1034
Access Time
Total random access time is ~7 to 20 millisecondsTotal random access time is ~7 to 20 milliseconds
![Page 35: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/35.jpg)
15-410, S’1035
Access Time
Total random access time is ~7 to 20 millisecondsTotal random access time is ~7 to 20 milliseconds 1000 ms/second, 20 ms/access = 50 accesses/second
![Page 36: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/36.jpg)
15-410, S’1036
Access Time
Total random access time is ~7 to 20 millisecondsTotal random access time is ~7 to 20 milliseconds 1000 ms/second, 20 ms/access = 50 accesses/second 50 ½-kilobyte transfers per second = 25 KByte/sec Oh man, disks are slow!
That's slower than DSL!!!
![Page 37: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/37.jpg)
15-410, S’1037
Access Time
Total random access time is ~7 to 20 millisecondsTotal random access time is ~7 to 20 milliseconds 1000 ms/second, 20 ms/access = 50 accesses/second 50 ½-kilobyte transfers per second = 25 Kbyte/sec Oh man, disks are slow!
That's slower than DSL!!! But wait! Disk transfer rates are hundreds of Mbytes/sec!
![Page 38: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/38.jpg)
15-410, S’1038
Access Time
Total random access time is ~7 to 20 millisecondsTotal random access time is ~7 to 20 milliseconds 1000 ms/second, 20 ms/access = 50 accesses/second 50 ½-kilobyte transfers per second = 25 Kbyte/sec Oh man, disks are slow!
That's slower than DSL!!! But wait! Disk transfer rates are hundreds of Mbytes/sec!
What can we, as O.S. programmers, do about this?What can we, as O.S. programmers, do about this? Read more per seek (multi-sector transfers) Don't seek so randomly (“disk scheduling”)
![Page 39: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/39.jpg)
15-410, S’1039
Disk Scheduling Algorithms
The goal of a disk scheduling algorithm is to be nice to The goal of a disk scheduling algorithm is to be nice to the diskthe disk
We can help the disk by giving it requests that are We can help the disk by giving it requests that are located close to each otherlocated close to each other This minimizes seek time, and possibly rotational latency
There exist a variety of ways to do thisThere exist a variety of ways to do this
![Page 40: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/40.jpg)
15-410, S’1040
Addressing Disks
What the OS knows about the diskWhat the OS knows about the disk Interface type (SATA/SCSI), unit number, number of sectors
What happened to sectors, tracks, etc?What happened to sectors, tracks, etc? Old disks were addressed by cylinder/head/sector (CHS) Modern disks are addressed by abstract sector number
LBA = logical block addressing
Who uses sector numbers?Who uses sector numbers? File systems assign logical blocks to files
TerminologyTerminology To disk people, “block” and “sector” are the same To file system people, a “block” is some number of sectors
![Page 41: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/41.jpg)
15-410, S’1041
Disk Addresses vs. Scheduling
Goal of OS disk-scheduling algorithmGoal of OS disk-scheduling algorithm Maintain queue of requests When disk finishes one request, give it the “best” request
E.g., whichever one is closest in terms of disk geometry
Goal of disk's logical addressingGoal of disk's logical addressing Hide messy details of which sectors are located where
Disk change fast – more than once a year OSs change slowly – up to 5 years for Windows
A good approximationA good approximation Older OS's tried to understand disk layout Modern OS's just assume nearby sector numbers are close
![Page 42: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/42.jpg)
15-410, S’1042
Scheduling Algorithms
““Don't try this at home”Don't try this at home”FCFSSSTF
Arguably less wrongArguably less wrongSCAN, C-SCAN
PlausiblePlausibleLOOK, C-LOOK
Useful, but hardUseful, but hardSPTF
![Page 43: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/43.jpg)
15-410, S’1043
First Come First Served (FCFS)
Send requests to disk as they are generated by the OSSend requests to disk as they are generated by the OS
Trivial to implement – FIFO queue in device driverTrivial to implement – FIFO queue in device driver
FairFair What could be more fair?
““Unacceptably high mean response time”Unacceptably high mean response time” File “abc” in sectors 1, 2, 3, ... File “def” in sectors 16384, 16385, 16386, ... Sequential reads: 1, 16384, 2, 16385, 3, 16386, …
(disk shakes so much it “walks” across the room)
![Page 44: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/44.jpg)
15-410, S’1044
Shortest Seek Time First (SSTF)
Maintain “queue” of disk requestsMaintain “queue” of disk requests
Serve the request nearest to the disk armServe the request nearest to the disk arm Estimate nearness by subtracting block numbers
Great!Great! Excellent throughput (most seeks are short) Very good average response time
Intolerable response time Intolerable response time variancevariance, however, however
Why?Why?
![Page 45: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/45.jpg)
15-410, S’1045
SSTF
Blue are requestsBlue are requests
Yellow is diskYellow is disk
Red is disk headRed is disk head
Green is completed requestsGreen is completed requests
Higher Block Numbers
![Page 46: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/46.jpg)
15-410, S’1046
SSTF
Higher Block Numbers
![Page 47: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/47.jpg)
15-410, S’1047
SSTF
Higher Block Numbers
![Page 48: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/48.jpg)
15-410, S’1048
SSTF
Higher Block Numbers
New Requests arrive…
![Page 49: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/49.jpg)
15-410, S’1049
SSTF
Higher Block Numbers
![Page 50: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/50.jpg)
15-410, S’1050
SSTF
Higher Block Numbers
![Page 51: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/51.jpg)
15-410, S’1051
SSTF
Higher Block Numbers
![Page 52: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/52.jpg)
15-410, S’1052
SSTF
Higher Block Numbers
Hey!
![Page 53: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/53.jpg)
15-410, S’1053
SSTF
Higher Block Numbers
Starves requests that are “far away” from the head
Request is starved
![Page 54: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/54.jpg)
15-410, S’1054
What Went Wrong?
FCFS - “fair, but slow”FCFS - “fair, but slow” Ignores position of disk arm, so its slow
SSTF – good throughput, very unfairSSTF – good throughput, very unfair Pays too much attention to requests near disk arm Ignores necessity of eventually scanning entire disk
![Page 55: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/55.jpg)
15-410, S’1055
What Went Wrong?
FCFS - “fair, but slow”FCFS - “fair, but slow” Ignores position of disk arm, so its slow
SSTF – good throughput, very unfairSSTF – good throughput, very unfair Pays too much attention to requests near disk arm Ignores necessity of eventually scanning entire disk
““Scan entire disk” - now that's an idea!Scan entire disk” - now that's an idea! Start disk arm moving in one direction Serve requests as the arm moves past them
No matter when they were queued When arm bangs into stop, reverse direction
![Page 56: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/56.jpg)
15-410, S’1056
SCAN
Blue are requestsBlue are requests
Yellow is diskYellow is disk
Red is disk headRed is disk head
Green is completed requestsGreen is completed requests
Higher Block Numbers
![Page 57: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/57.jpg)
15-410, S’1057
SCAN
Higher Block Numbers
![Page 58: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/58.jpg)
15-410, S’1058
SCAN
Higher Block Numbers
![Page 59: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/59.jpg)
15-410, S’1059
SCAN
Higher Block Numbers
![Page 60: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/60.jpg)
15-410, S’1060
SCAN
Higher Block Numbers
![Page 61: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/61.jpg)
15-410, S’1061
SCAN
Higher Block Numbers
New Request
SSTF would reverse here
![Page 62: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/62.jpg)
15-410, S’1062
SCAN
Higher Block Numbers
New Request
![Page 63: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/63.jpg)
15-410, S’1063
SCAN
Higher Block Numbers
![Page 64: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/64.jpg)
15-410, S’1064
SCAN
Higher Block Numbers
In SCAN, we continue to the end of the disk
![Page 65: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/65.jpg)
15-410, S’1065
SCAN
Higher Block Numbers
![Page 66: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/66.jpg)
15-410, S’1066
SCAN
Higher Block Numbers
![Page 67: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/67.jpg)
15-410, S’1067
SCAN
Higher Block Numbers
![Page 68: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/68.jpg)
15-410, S’1068
SCAN
Higher Block Numbers
![Page 69: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/69.jpg)
15-410, S’1069
SCAN
Higher Block Numbers
![Page 70: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/70.jpg)
15-410, S’1070
SCAN
Higher Block Numbers
![Page 71: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/71.jpg)
15-410, S’1071
SCAN
Higher Block Numbers
![Page 72: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/72.jpg)
15-410, S’1072
SCAN
Higher Block Numbers
![Page 73: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/73.jpg)
15-410, S’1073
SCAN
Higher Block Numbers
![Page 74: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/74.jpg)
15-410, S’1074
SCAN
Higher Block Numbers
![Page 75: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/75.jpg)
15-410, S’1075
Evaluating SCAN
Mean response timeMean response time Worse than SSTF, better than FCFS You should be able to say why
Response time Response time variancevariance Better than SSTF
Do we need to go all the way to the end of the disk?Do we need to go all the way to the end of the disk?
![Page 76: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/76.jpg)
15-410, S’1076
The LOOK Optimization
Just like SCAN – sweep back and forth through Just like SCAN – sweep back and forth through cylinderscylinders
Don't wait for the “thud” to reverse the scanDon't wait for the “thud” to reverse the scan Reverse when there are no requests “ahead” of the arm
Improves mean response time, varianceImproves mean response time, variance
Both SCAN and LOOK are unfair – why?Both SCAN and LOOK are unfair – why?
![Page 77: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/77.jpg)
15-410, S’1077
C-SCAN - “Circular SCAN”Send requests in ascending cylinder orderSend requests in ascending cylinder order
When the last cylinder is reached, seek all the way When the last cylinder is reached, seek all the way back to the first cylinderback to the first cylinder
Long seek is amortized across all accessesLong seek is amortized across all accesses Key implementation detail
Seek time is a non-linear function of seek distance One big seek is faster than N smaller seeks
Variance is improvedVariance is improved
FairFair
Still missing something though…Still missing something though…
Oklobdzija, Comp. Eng. Handbook, 2002
![Page 78: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/78.jpg)
15-410, S’1078
C-LOOK
CSCAN + LOOKCSCAN + LOOK
Scan in one direction, as in CSCANScan in one direction, as in CSCAN
If there are no more requests in current direction go If there are no more requests in current direction go back to furthest requestback to furthest request
Very popularVery popular
![Page 79: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/79.jpg)
15-410, S’1079
C-LOOK
Higher Block Numbers
![Page 80: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/80.jpg)
15-410, S’1080
C-LOOK
Higher Block Numbers
![Page 81: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/81.jpg)
15-410, S’1081
C-LOOK
Higher Block Numbers
![Page 82: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/82.jpg)
15-410, S’1082
C-LOOK
Higher Block Numbers
![Page 83: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/83.jpg)
15-410, S’1083
C-LOOK
Higher Block Numbers
![Page 84: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/84.jpg)
15-410, S’1084
C-LOOK
Higher Block Numbers
New Request
![Page 85: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/85.jpg)
15-410, S’1085
C-LOOK
Higher Block Numbers
![Page 86: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/86.jpg)
15-410, S’1086
C-LOOK
Higher Block Numbers
In SCAN, we would continue right until the end of the disk
![Page 87: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/87.jpg)
15-410, S’1087
C-LOOK
Higher Block Numbers
![Page 88: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/88.jpg)
15-410, S’1088
C-LOOK
Higher Block Numbers
In LOOK, we would have read this request(unfair extra service—so we'll skip it)
![Page 89: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/89.jpg)
15-410, S’1089
C-LOOK
Higher Block Numbers
![Page 90: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/90.jpg)
15-410, S’1090
C-LOOK
Higher Block Numbers
![Page 91: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/91.jpg)
15-410, S’1091
C-LOOK
Higher Block Numbers
![Page 92: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/92.jpg)
15-410, S’1092
C-LOOK
Higher Block Numbers
![Page 93: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/93.jpg)
15-410, S’1093
C-LOOK
Higher Block Numbers
![Page 94: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/94.jpg)
15-410, S’1094
C-LOOK
Higher Block Numbers
![Page 95: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/95.jpg)
15-410, S’1095
C-LOOK
Higher Block Numbers
![Page 96: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/96.jpg)
15-410, S’1096
C-LOOK
Higher Block Numbers
![Page 97: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/97.jpg)
15-410, S’1097
Algorithm Classification
SCAN vs. LOOKSCAN vs. LOOK LOOK doesn't visit far edges of disk unless there are
requests
LOOK vs. C-LOOKLOOK vs. C-LOOK C for “circular” - don't double-serve middle sectors
We are now excellent disk-arm schedulersWe are now excellent disk-arm schedulers Done, right?
![Page 98: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/98.jpg)
15-410, S’1098
Shortest Positioning Time First
Key observationKey observation Seek time takes a while, C-LOOK is a reasonable response But rotational delay is comparable!
More: short seeks are faster than whole-disk rotations What matters is positioning time, not seek time
SPTF is like SSTFSPTF is like SSTF Serve “temporally nearest” sector next
ChallengeChallenge Driver can't estimate positions from sector numbers Must know layout, plus rotation position of disk in real time!
Performs better than SSTF, but still starves requestsPerforms better than SSTF, but still starves requests
![Page 99: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/99.jpg)
15-410, S’1099
Weighted Shortest Positioning Time First (WSPTF)
SPTF plus fairnessSPTF plus fairness
Requests are “aged” to prevent starvationRequests are “aged” to prevent starvation Compute “temporal distance” to each pending request Subtract off “age factor” - old requests are artificially close Result: sometimes serve old request, not closest request
Various aging policies possible, many work fineVarious aging policies possible, many work fine
Excellent performanceExcellent performance
As SPTF, hard for OS to know disk status in real timeAs SPTF, hard for OS to know disk status in real time On-disk schedulers can manage this, though...
Some disks (SATA, SCSI) accept a request queue Sector complete ⇒ give OS both data and sector number
![Page 100: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/100.jpg)
15-410, S’10100
Scheduling Concept Summary
LOOK vs SCANLOOK vs SCAN SCAN goes to the very end of the disk LOOK goes only as far as the farthest request
2-way vs circular2-way vs circular 2-way reverses directions at the extremes, unfair Circular starts back at the “starting” position
Modern disks queue internally, using positioning timeModern disks queue internally, using positioning time Head of request queue managed by disk – two-level scheduler
FairnessFairness “High-throughput” algorithms can starve requests “Complete fairness” is slow Balance somehow... “aging” is one option
![Page 101: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/101.jpg)
15-410, S’10101
Lies Disks Tell
Disks serve read requests out of orderDisks serve read requests out of order OS queues: “read 37”, “read 83”, “read 2”
Disk returns 37, 2, 83 Great! That's why we buy smart disks and queue multiple
requests
Disks serve Disks serve writewrite requests out of order, too requests out of order, too You ask “write 23”, “write 24”, “write 1000”, “read 4-8”, ...
Disk writes 24, 23 (!!), gives you 4, 5, 6, 7, 8, writes 1000 What if power fails before last write? What if power fails between first two writes?
![Page 102: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/102.jpg)
15-410, S’10102
Lies Disks Tell
Forcing truth (when necessary)Forcing truth (when necessary) Special commands
“Flush all pending writes” Think “my disk is 'modern'”, think “disk barrier” Can even queue a flush to apply to all before now Can apply these “barrier” flushes to subsets of requests
Rarely used by operating system “Disable write cache”
Think “please don't be quite so modern”
![Page 103: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/103.jpg)
15-410, S’10103
Conclusions
Disks are mechanical (voice coil == speakers)Disks are mechanical (voice coil == speakers)
Disks are slow, best if accesses are big & sequentialDisks are slow, best if accesses are big & sequential
Disks are complicated (there's a computer inside)Disks are complicated (there's a computer inside)
FCFS is a very bad ideaFCFS is a very bad idea C-LOOK is ok in practice Disks probably do something like SPTF internally
Disks lieDisks lie Some lies are good for performance, but be careful!
![Page 104: Disks Mar. 21, 2005](https://reader031.vdocuments.site/reader031/viewer/2022012013/61583c770bb1426ff33be291/html5/thumbnails/104.jpg)
15-410, S’10104
Further Reading
Terabyte TerritoryTerabyte TerritoryBrian HayesAmerican Scientist, May/June 2002http://www.americanscientist.org/template/AssetDetail/assetid/14750?&print=yes
A Conversation with Jim GrayA Conversation with Jim GrayDave PattersonACM Queue, June 2003http://www.acmqueue.org/modules.php?name=Content&pa=showpage&pid=43