Upload
kioshi
View
52
Download
1
Tags:
Embed Size (px)
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 Presentation
Citation preview
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– Driver– Interrupt Service Routine
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
No Buffers: T + C
Disk User Copy CPU
T
Disk User Copy CPU
C
One Buffer: max(T, C) + M
System BufferDisk User Copy CPU
System BufferDisk User Copy CPU
T C
M
Two Buffers: max(T, C + M)
SystemBuffer 1
Disk
UserCopy
CPUT
C
SystemBuffer 2
UserCopy
CPU
M
SystemBuffer 2
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.
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.
Disk Layout
Sector
Track
Intersector Gap
Intertrack Gap
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
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
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
FIFO, Priority, and LIFO
DiskEnter
DiskEnter
Enter
Disk
Enter
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
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
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
N-step-Scan
23 Disk2 7 11 15
Jobs entered in sorted groups of N jobs
GroupsServicedIn FIFOOrder
Case whereN = 1 is FIFO
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
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
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
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
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)
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
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
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
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
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)