i/o and disk scheduling
DESCRIPTION
I/O and Disk Scheduling. CS 470 - Spring 2002. Overview. Review of I/O Techniques I/O Buffering Disk Geometry Disk Scheduling Algorithms RAID. Review. Input / Output techniques Programmed I/O Interrupt Driven I/O Direct Memory access I/O Layering Application Device Independent I/O - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/1.jpg)
I/O and Disk Scheduling
CS 470 - Spring 2002
![Page 2: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/2.jpg)
Overview
• Review of I/O Techniques
• I/O Buffering
• Disk Geometry
• Disk Scheduling Algorithms
• RAID
![Page 3: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/3.jpg)
Review
• Input / Output techniques– Programmed I/O– Interrupt Driven I/O– Direct Memory access
• I/O Layering– Application– Device Independent I/O– Driver– Interrupt Service Routine
![Page 4: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/4.jpg)
I/O Buffering
• Advantages– Overlap I/O and computation– Separates I/O from computation e.g. I/O can
occur even if buffer is swapped
• Time measurement parameters – T = I/O transfer time– C = computation time–M = block move time
• Effect of buffering on program performance
![Page 5: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/5.jpg)
No Buffers: T + C
Disk User Copy CPU
T
Disk User Copy CPU
C
![Page 6: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/6.jpg)
One Buffer: max(T, C) + M
System BufferDisk User Copy CPU
System BufferDisk User Copy CPU
T C
M
![Page 7: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/7.jpg)
Two Buffers: max(T, C + M)
SystemBuffer 1
Disk
UserCopy
CPUT
C
SystemBuffer 2
UserCopy
CPU
M
SystemBuffer 2
![Page 8: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/8.jpg)
I/O Buffering Summary• Buffering Alternatives– No buffering: T + C– Single buffer: max(T, C) + M– Double buffer: max(T, C + M)– Circular buffers: smooths out I/O demand
• Disk cache - analogy to memory management – Fetch Policy - read ahead– Replacement choice: LRU, LFU, FIFO–When to do these: On demand or
preplanned.
![Page 9: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/9.jpg)
Classic Disk Geometry• Disk medium is a number of platters fixed
to a axle spinning at high speed.
• There is one read/write head for each surface of each platter. Heads are attached to an arm which varies by discrete amounts the distance to the axle of all heads simultaneously.
• For each position of the arm, a head describes a circular track as the disk spins. Track is divided into segments called sectors which hold the data.
![Page 10: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/10.jpg)
Disk Layout
Sector
Track
Intersector Gap
Intertrack Gap
![Page 11: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/11.jpg)
Disk Performance• Seek time: time to move arm to right
cylinder. Roughly linear in nbr. of tracks crossed: #tracks Trk2Trk + Startup. Average is seek over half the tracks.
• Rotational delay: time to spin around to right sector on track
• Access time: seek time + rotational delay• Transfer speed: how fast data spins past
the head• Rotational speed and average seek time
determine these parameters
![Page 12: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/12.jpg)
Retail $100 IDE Disk Drive• Geometry– 8 platters (16 surfaces, 16 heads, 1 arm)– 7763 cylinders (7763 tracks per surface)– 63 sectors of 512 bytes each per track– Total: 16 7763 63 512 bytes = 3913 MB
• Performance– Avg seek: 11 ms, Rotational speed: 5400 rpm– Avg rot. delay: 0.5/5400 min = 5.5 ms– Avg access time: 11 + 5.5 = 16.5 ms– trans speed: 63 5400 512 b/m = 2.8
MB/sec
![Page 13: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/13.jpg)
Disk Scheduling Algorithms
• FIFO - simple and fair
• Priority
• LIFO - serve current process well
• Shortest service time first (SSTF)
• SCAN - Back and forth over disk
• C-SCAN - unidirectional scan
• N-step SCAN - N jobs per queue
• FSCAN - 2 queues
![Page 14: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/14.jpg)
FIFO, Priority, and LIFO
DiskEnter
DiskEnter
Enter
Disk
Enter
![Page 15: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/15.jpg)
Shortest Service Time Next
23 Disk
Jobs Entered In Sorted Order
2 7 11 15
10 Current Location
Select Closest Job
Starvation when arm is stuck inone area for extended period
Numbers areDisk locationsof data
![Page 16: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/16.jpg)
Scan (Bidirectional)
23 Disk
Jobs Entered In Sorted Order
2 7 11 15
10 Current Location
Scan Left to Right, Then Right to Left
Uneven response time at ends of disk
![Page 17: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/17.jpg)
C-Scan (Unidirectional)
23 Disk
Jobs Entered In Sorted Order
2 7 11 15
10 Current Location
Scan Left to Right, Then Return to left
Can Still Exhibit Starvation
![Page 18: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/18.jpg)
N-step-Scan
23 Disk2 7 11 15
Jobs entered in sorted groups of N jobs
GroupsServicedIn FIFOOrder
Case whereN = 1 is FIFO
![Page 19: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/19.jpg)
F-Scan
23
Disk
2 7 11 15
Jobs Queued in Sorted Order
Roles of two groups swapped whencurrent group of jobs serviced.
Queue Group
Dequeue Group
![Page 20: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/20.jpg)
Basic Disks
• Master boot record (MBR)– Located on first sector of primary drive– Boot code– Partition Table (Up to 4 Entries)• Location and size of partition• File system type (e.g. FAT32, NTFS)• Extended Partition is a file system type
– Recursively contains MBR and Partitions itself
• Partitions– File System begins with boot sector
![Page 21: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/21.jpg)
Dynamic Disks (1 of 2)
• Logical Disk Manager (LDM) Database– Single database for all drives – includes
multipartition volume descriptions– Replicated with one copy on each dynamic
drive– 1 MB in size, located at end of drive
• Master Boot Record (MBR)– Describes System and Boot partitions– If none, single partition from MBR to LDM– Boot and legacy software can’t read LDM
![Page 22: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/22.jpg)
Dynamic Disks (2 of 2)• LDM Structure– Private Header• GUID for dynamic drive and disk group name• Replicated at end of LDM
– Table of Contents– 128 byte database records• Entries all have name and id• Partitions: size, offset, disk id, parent component• Components: parent volume (2 for mirrors)• Volume: size, state, GUID, drive hint• Disk: GUID
– Transactional Log
![Page 23: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/23.jpg)
RAID• Redundant Array of Independent Disks
• Six flavors– Level 0: Disk striping– Level 1: Disk mirroring– Level 2: Small strips, ECC e.g. Hamming– Level 3: Small strips with parity– Level 4: Large strips, fixed parity drive– Level 5: Large strips, round robin parity
• Disk Spanning (not RAID)
![Page 24: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/24.jpg)
Striping and Mirroring
15
10
5
0
16
11
6
1
17
12
7
2
18
13
8
3
19
14
9
4
3
2
1
0
3
2
1
0 Mirroring Provides DataRedundancy at cost of doubling number of drivesHas Fast Read Access
Stripes are fast; but not redundant
![Page 25: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/25.jpg)
Raid Levels 2 and 3
15
10
5
0
17
12
7
2
19
14
9
4
C
C
C
C
C
C
C
C
16
11
6
1
18
13
8
3
Disk arms are in lock step; each accessinvolves all disk drives. Fast access forlarge individual jobs - high overhead for many small I/O’s.Level 2 avoided because of added cost.
Small Byte-sized Strips Redundancy
![Page 26: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/26.jpg)
Raid Levels 4 and 5
15
10
5
0
17
12
7
2
19
14
9
4
P
P
P
P
16
11
6
1
18
13
8
3
Large Strips with Parity Strip
15
10
5
P
17
P
6
1
18
13
8
3
19
14
9
4
16
11
P
0
P
12
7
2
Single drivefor paritystays verybusy
Round robinparity
![Page 27: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/27.jpg)
RAID Level 4 and 5
• Redundancy Principle– Bit values for parity drive are sum mod 2 of
the corresponding bits on other drives
• When a block is changed, the new parity can be computed in terms of the old value of the parity:– new parity = sum of old & new value and old
parity bit modulo 2– So one write requires: 2 reads and 2 writes
• Reading requires just one read
![Page 28: I/O and Disk Scheduling](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813b41550346895da416d8/html5/thumbnails/28.jpg)
RAID 5 Sector Calculation
• Assume:– RAID 5 with k drives and sector sized strips– Sector/Drive numbers zero based
• Effective capacity is k-1 times the size of a single drive
• RAID logical sector N location:– R = N % (k * (k - 1)) – Drive = R%(k-1) + ((R%(k-1)>=R/(k-1)) ? 1 : 0)– Sector = N / (k - 1)– Parity Drive = R / (k – 1)