i/o management and disk scheduling - university of...
TRANSCRIPT
I/O Management and Disk Scheduling
Chapter 11(read 11.1, 11.2)
Dr. Otman Basir Winter 2006
E&CE 354: Processes 0
Operating System Design IssuesEfficiency
Most I/O devices extremely slow compared to main memoryUse of multiprogramming allows for some processes to be waiting on I/O while another process executesI/O cannot keep up with processor speedSwapping is used to bring in additional Ready processes which is an I/O operation
Dr. Otman Basir Winter 2006
E&CE 354: Processes 1
Operating System Design IssuesGenerality
Desirable to handle all I/O devices in a uniform mannerHide most of the details of device I/O in lower-level routines so that processes and upper levels see devices in general terms such as read, write, open, close, lock, unlock,…, etc.
Dr. Otman Basir Winter 2006
E&CE 354: Processes 2
Logical Structure of I/OLogical I/O
treats device as logical resource with no concerns of details of controlmanages I/O functions on behalf of user process
Device I/Oconvert requested operations in to sequences of I/O instructions, channel commands, and controller orders
Scheduling and Controlqueuing and scheduling of I/O operationshandle interrupts, check I/O status,…
Dr. Otman Basir Winter 2006
E&CE 354: Processes 3
Logical Structure of I/OFor secondary storage devices with a file system:
Directory Managementconvert symbolic file names to identifiers that reference directly/indirectly the filemanage user add, delete, reorganize operations
File Systemlogical structure of files and operations that can be specified by user
Physical Organizationconvert logical references to files/records to physical storage addresses
Dr. Otman Basir Winter 2006
E&CE 354: Processes 4
I/O BufferingReasons for buffering
Processes must wait for I/O to complete before proceeding
Certain pages must remain in main memory during I/O
• Page containing I/O target must remain• Not possible to entirely swap out waiting
process
Dr. Otman Basir Winter 2006
E&CE 354: Processes 5
I/O BufferingI/O devices:
Block-orientedInformation is stored in fixed sized blocksTransfers are made a block at a timeUsed for disks and tapes
Stream-orientedTransfer information as a stream of bytesUsed for terminals, printers, communication ports, mouse, and most other devices that are not secondary storage
Dr. Otman Basir Winter 2006
E&CE 354: Processes 6
Single Buffer[1]Operating system assigns a buffer in main memory for an I/O requestBlock-oriented
Input transfers made to bufferBlock moved to user space when neededAnother block is moved into the buffer
• Read ahead
Dr. Otman Basir Winter 2006
E&CE 354: Processes 7
Single Buffer[2]Block-oriented
User process can process one block of data while next block is read in
Swapping can occur since input is taking place in system memory, not user memory
Operating system keeps track of assignment of system buffers to user processes
Dr. Otman Basir Winter 2006
E&CE 354: Processes 8
Single Buffer[3]Stream-oriented
Used a line at time
User input from a terminal is one line at a time with carriage return signaling the end of the line
Output to the terminal is one line at a time
Dr. Otman Basir Winter 2006
E&CE 354: Processes 9
Double BufferUse two system buffers instead of one
A process can transfer data to or from one buffer while the operating system empties or fills the other buffer
Dr. Otman Basir Winter 2006
E&CE 354: Processes 10
Circular BufferMore than two buffers are used
Each individual buffer is one unit in a circular buffer
Used when I/O operation must keep up with process
Dr. Otman Basir Winter 2006
E&CE 354: Processes 11
Disk Performance ParametersTo read or write, the disk head must be positioned at the desired track and at the beginning of the desired sectorSeek time
time it takes to position the head at the desired track
Rotational delay or rotational latencytime its takes for the beginning of the sector to reach the head
Dr. Otman Basir Winter 2006
E&CE 354: Processes 12
Timing of a Disk I/O Transfer
Dr. Otman Basir Winter 2006
E&CE 354: Processes 13
Disk Performance ParametersAccess time
Sum of seek time and rotational delayThe time it takes to get in position to read or write
Data transfer occurs as the sector moves under the head
Dr. Otman Basir Winter 2006
E&CE 354: Processes 14
Disk Performance ParametersTransfer Time
depends on rotational speed as:
seek time average theis where21
:as expressed timeaccess average totalThesecond)per ns(revolutio speedrotation
trackaon bytes ofnumber ed transferrbe tobytes ofnumber
time transfer
:where
s
sd
TrNb
rTT
rNbT
rNbT
++=
====
=
Dr. Otman Basir Winter 2006
E&CE 354: Processes 15
Disk Scheduling Policies[1]Seek time is the reason for differences in performance
For a single disk there will be a number of I/O requests
If requests are selected randomly, we will get the worst possible performance
Dr. Otman Basir Winter 2006
E&CE 354: Processes 16
Disk Scheduling Policies[2]First-in, first-out (FIFO)
Process requests put in queue sequentially
Fair to all processes
Approaches random scheduling in performance if there are many processes
Dr. Otman Basir Winter 2006
E&CE 354: Processes 17
Disk Scheduling Policies[3]Priority
Goal is not to optimize disk use but to meet other objectives
Short batch jobs may have higher priority
Provide good interactive response time
Dr. Otman Basir Winter 2006
E&CE 354: Processes 18
Disk Scheduling Policies[5]Shortest Service Time First
Select the disk I/O request that requires the least movement of the disk arm from its current position
Always choose the minimum Seek time
Dr. Otman Basir Winter 2006
E&CE 354: Processes 20
Disk Scheduling Policies[6]SCAN
Arm moves in one direction only, satisfying all outstanding requests until it reaches the last track in that direction [or no more requests in that direction – LOOK policy]
Direction is reversed
Biased against area most recently traversed
Dr. Otman Basir Winter 2006
E&CE 354: Processes 21
Disk Scheduling Policies[7]C-SCAN
Restricts scanning to one direction only
When the last track has been visited in one direction, the arm is returned to the opposite end of the disk and the scan begins again [also C-LOOK variant]
Dr. Otman Basir Winter 2006
E&CE 354: Processes 22
Disk Scheduling Policies[8]N-step-SCAN
Segments the disk request queue into subqueuesof length NSubqueues are processed one at a time, using SCANNew requests added to some other queue when queue is processed
FSCANTwo queuesOne queue is empty for new request
Dr. Otman Basir Winter 2006
E&CE 354: Processes 23
Comparisonassume track requests are 55, 58, 39, 18, 90, 160, 150, 38, 184 and the current track is 100:
FIFO SSTF SCAN C-SCANNxt Trk # Trks Nxt Trk # Trks Nxt Trk # Trks Nxt Trk # Trks
55 45 90 10 150 50 150 5058 3 58 32 160 10 160 1039 19 55 3 184 24 184 2418 21 39 16 90 94 18 16690 72 38 1 58 32 38 20
160 70 18 20 55 3 39 1150 10 150 132 39 16 55 1638 112 160 10 38 1 58 3
184 146 184 24 18 20 90 32Avg: 55.3 Avg: 27.5 Avg: 27.8 Avg: 35.8
Dr. Otman Basir Winter 2006
E&CE 354: Processes 24
RAIDOrganize data in which redundancy can be added to improve reliability
Redundant Array of Independent Disks (RAID)
set of physical disk drives viewed by OS as a single logical drive
data distributed across drives in array
redundant disk capacity used to store parity info
• ensures recoverability in event of disk failure
Dr. Otman Basir Winter 2006
E&CE 354: Processes 25
RAIDCategory Level Description I/O Req. Rate Transfer Rate Typ. App.
Stripping 0 Non-redundant Large strips: Excellent
Small Strips:Excellent
high performance, non critical data
Mirroring 1 Mirrored Good/Fair Fair/fair System drives; critical files
2 Redundant via Hamming code
Poor Excellent
3 Bit-interleaved parity Poor Excellent Big I/O req. size
4 Block-interleaved parity Excellent/fair Fair/poor
5 Block-interleaved distributed parity
Excellent/fair Fair/poor High req. rate, read intensive
6 Block-interleaved dual distributed parity
Excellent/poor Fair/poor need very high availability
Independent Access
Parallel Access
Dr. Otman Basir Winter 2006
E&CE 354: Processes 26
RAID 0 (non-redundant)
high performance but
not true RAID
Dr. Otman Basir Winter 2006
E&CE 354: Processes 27
Dr. Otman Basir Winter 2006
E&CE 354: Processes 28
RAID 1 (mirrored)
Dr. Otman Basir Winter 2006
E&CE 354: Processes 29
RAID 1 (mirrored)redundancy achieved by simple duplication of all dataadvantages:
read requests can be serviced by either diskwrite requires both strips be updated but it can be done in parallelrecovery from single drive failure simple: data may still be accessed from other drive.
primary disadvantage:cost of twice the disk space required
Dr. Otman Basir Winter 2006
E&CE 354: Processes 30
RAID 2 (redundancy through Hamming code)
Dr. Otman Basir Winter 2006
E&CE 354: Processes 31
RAID 2all disks participate in disk transfers, spindles synchronized so each disk head is in same position on each diskerror correcting code calculated across corresponding bits on each data disk; bits of code stored in corresponding bit positions on multiple parity diskssingle-bit errors recognized and corrected immediately with no impact on access timeon single write, all data and parity disks must be accessedgenerally an overkill solution and not used given the high reliability of modern disks
Dr. Otman Basir Winter 2006
E&CE 354: Processes 32
RAID 3 (bit-interleaved parity)
Dr. Otman Basir Winter 2006
E&CE 354: Processes 33
RAID 3uses only one redundant diskuses parallel access, data distributed in small stripscompute a simple parity bit for the set of individual bits in same position on all of the data disksexample: disks X0, X1, X2, X3 store data and X4 stores parity
parity for i-th bit calculated as:X4(i) = X3(i) ⊕ X2(i) ⊕ X1(i) ⊕ X0(i)
let X1 fail, then add x4(i) ⊕ X1(i) to both sides as:X1(i) = X4(i) ⊕ X3(i) ⊕ X2(i) ⊕ X0(i)
Dr. Otman Basir Winter 2006
E&CE 354: Processes 34
RAID 4 (block-level parity)
Dr. Otman Basir Winter 2006
E&CE 354: Processes 35
RAID 4uses independent access array – each disk operates independently --> separate I/O requests can be satisfied in parallela bit-by-bit parity strip calculated across corresponding strips on each data disk
parity bits stored in corresponding strip on parity disk
penalty on small size writesupdate data + corresponding parity bits
Dr. Otman Basir Winter 2006
E&CE 354: Processes 36
RAID 4consider X0 … X3 data disks and X4 is parity diskwe have following relationship:
X4(i) = X3(i) ⊕ X2(i) ⊕ X1(i) ⊕ X0(i)after update (altered bits indicated by prime):X4’(i) = X3(i) ⊕ X2(i) ⊕ X1’(i) ⊕ X0(i)
= X3(i) ⊕ X2(i) ⊕ X1’(i) ⊕ X0(i) ⊕ X1(i) ⊕ X1(i)= X4(i) ⊕ X1(i) ⊕ X1’(i)
update requires 2 reads and 2 writesfor larger size I/O writes that involve strips on all disks, parity calculated using only new data bits
parallel update of parity and data – no extra reads/writes
Dr. Otman Basir Winter 2006
E&CE 354: Processes 37
RAID 5 (block-level distributed parity)
Dr. Otman Basir Winter 2006
E&CE 354: Processes 38
RAID 5
similar to RAID 4 except parity strips distributed across all disks
this distribution of parity strips avoids potential I/O bottleneck of single disk parity of RAID 4
Dr. Otman Basir Winter 2006
E&CE 354: Processes 39
RAID 6 (dual redundancy)Q(0-3)
Dr. Otman Basir Winter 2006
E&CE 354: Processes 40
RAID 6two different parities are carried and stored in separate blocks on different disks
user with N disk requirement needs N+2 disk configuration
possible to regenerate data even if two disks containing user data fail
extremely high availability but substantial write penalty since each write affects two parity blocks
Dr. Otman Basir Winter 2006
E&CE 354: Processes 41
Disk CacheBuffer in main memory for disk sectors
Contains a copy of some of the sectors on the disk
On I/O request, check if required sector is in disk cache
Different replacement strategies possible, for example:
least recently used (LRU)
least frequently used (LFU)
Dr. Otman Basir Winter 2006
E&CE 354: Processes 42
Least Recently UsedThe block that has been in the cache the longest with no reference to it is replaced
The cache consists of a stack of blocks
Most recently referenced block is on the top of the stack
When a block is referenced or brought into the cache, it is placed on the top of the stack
Dr. Otman Basir Winter 2006
E&CE 354: Processes 43
Least Recently UsedThe block on the bottom of the stack is removed when a new block is brought in
Blocks don’t actually move around in main memory
A stack of pointers is used
Dr. Otman Basir Winter 2006
E&CE 354: Processes 44
Least Frequently UsedThe block that has experienced the fewest references is replaced
A counter is associated with each block
Counter is incremented each time block accessed
Block with smallest count is selected for replacement
Some blocks may be referenced many times in a short period of time and then not needed any more
Dr. Otman Basir Winter 2006
E&CE 354: Processes 45
UNIX SVR4 I/O
Dr. Otman Basir Winter 2006
E&CE 354: Processes 46
Windows 2000 I/O
Dr. Otman Basir Winter 2006
E&CE 354: Processes 47