Presentation on theme: "Chapter 11 I/O Management and Disk Scheduling"— Presentation transcript:
1 Chapter 11 I/O Management and Disk Scheduling Operating System Design IssuesI/O BufferingDisk SchedulingDisk Cache
2 Goal: GeneralityFor simplicity and freedom from error, it’s better to handle all I/O devices in a uniform mannerDue to the diversity of device characteristics, it is difficult in practice to achieve true generalitySolution: use a hierarchical modular design of I/O functionsHide details of device I/O in lower-level routinesUser processes and upper levels of OS see devices in terms of general functions, such as read, write, open, close, lock, unlock
3 A Model of I/O Organization Logical I/O:Deals with the device as a logical resource and is not concerned with the details of actually controlling the deviceAllows user processes to deal with the device in terms of a device identifier and simple commands such as open, close, read, writeDevice I/O:Converts requested operations into sequence of I/O instructionsUses buffering techniques to improve utilization
4 A Model of I/O Organization Scheduling and Control:Performs actual queuing / scheduling and control operationsHandles interrupts and collects and reports I/O statusInteracts with the I/O module and hence the device hardware
5 Goal: EfficiencyMost I/O devices are extremely slow compared to main memory I/O operations often form a bottleneck in a computing systemMultiprogramming allows some processes to be waiting on I/O while another process is executing
6 Goal: EfficiencySwapping brings in ready processes but this is an I/O operation itselfA major effort in I/O design has been schemes for improving the efficiency of I/OI/O bufferingDisk schedulingDisk cache
7 Roadmap Operating System Design Issues I/O Buffering Disk Scheduling Disk Cache
8 No BufferingWithout a buffer, OS directly accesses the device as and when it needsA data area within the address space of the user process is used for I/O
9 No Buffering Process must wait for I/O to complete before proceeding busy waiting (like programmed I/O)process suspension on an interrupt (like interrupt-driven I/O or DMA)Problemsthe program is hung up waiting for the relatively slow I/O to completeinterferes with swapping decisions by OS
10 No BufferingIt is impossible to swap the process out completely because the data area must be locked in main memory before I/OOtherwise, data may be lost or single-process deadlock may happenthe suspended process is blocked waiting on the I/O event, and the I/O operation is blocked waiting for the process to be swapped in
11 I/O BufferingIt may be more efficient to perform input transfers in advance of requests being made and to perform output transfers some time after the request is made.
12 Block-oriented Buffering For block-oriented I/O devices such asdisks andUSB drivesInformation is stored in fixed sized blocksTransfers are made a block at a timeCan reference data by block number
13 Stream-Oriented Buffering For stream-oriented I/O devices such asterminalsprinterscommunication portsmouse and other pointing devices, andmost other devices that are not secondary storageTransfer information as a stream of bytes
14 Single BufferOS assigns a buffer in the system portion of main memory for an I/O request
15 Block Oriented Single Buffer Input transfers are made to system bufferBlock moved to user space when neededThe next block is immediately requested, expecting that the block will eventually be neededRead ahead or Anticipated InputA reasonable assumption as data is usually accessed sequentially
16 Block Oriented Single Buffer Provide a speedupUser process can be processing one block of data while the next block is being read in OS is able to swap the process out because the I/O operation is taking place in system memory
17 Block Oriented Single Buffer Complicate the logic in OSOS must keep track of the assignment of system buffers to user processes Affect the swapping logicConsider both the I/O operation and swapping involve the same diskDoes it make sense to swap the process out after the I/O operation finishes?
18 Stream-oriented Single Buffer Line-at-time or Byte-at-a-timeTerminals often deal with one line at a time with carriage return signaling the end of the lineAlso line printerByte-at-a-time suits devices where a single keystroke may be significantAlso sensors and controllersInteraction between OS and user process follows the producer/consumer model
19 Double Buffer Use two system buffers instead of one A process can transfer data to or from one buffer while OS empties or fills the other buffer
20 Circular Buffer More than two buffers are used Each individual buffer is one unit in a circular bufferUsed when I/O operation must keep up with processFollows the bounded-buffer producer/consumer model
21 Buffer Limitations Buffering smoothes out peaks in I/O demand But with enough demand eventually all buffers become full and their advantage is lostIn multiprogramming environment, buffering can increase the efficiency of OS and the performance of individual processes
22 Roadmap Operating System Design Issues I/O Buffering Disk Scheduling Disk Cache
23 Disk Performance Parameters Currently, disks are at least four orders of magnitude slower than main memory performance of disk storage subsystem is of vital concernA general timing diagram of disk I/O transfer is shown here.
24 Positioning the Read/Write Heads When the disk drive is operating, the disk is rotating at constant speed.To read or write, the head must be positioned at the desired track and at the beginning of the desired sector on that track.Track selection involves moving the head in a movable-head system.
25 Disk Performance Parameters Access Time is the sum of:Seek time: The time it takes to position the head at the desired trackRotational delay or rotational latency: The time it takes for the beginning of the sector to reach the headTransfer Time is the time taken to transfer the data (as the sector moves under the head)
26 Disk Performance Parameters Total average access time TaTa = Ts + 1 / (2r) + b / (rN)where Ts = average seek timeb = no. of bytes to be transferredN = no. of bytes on a trackr = rotation speed, in revolutions / sec.Due to the seek time, the order in which sectors are read from disk has a tremendous effect on I/O performance
27 Disk Scheduling Policies To compare various schemes, consider a disk head is initially located at track 100.assume a disk with 200 tracks and that the disk request queue has random requests in it.The requested tracks, in the order received by the disk scheduler, are55, 58, 39, 18, 90, 160, 150, 38, 184.
28 First-in, first-out (FIFO) Process requests sequentiallyFair to all processesMay have good performance if most requests are to clustered file sectorsApproaches random scheduling in performance if there are many processesdisk arm movement
29 PriorityControl of the scheduling is outside the control of disk management softwareGoal is not to optimize disk use but to meet other objectivesOften, short batch jobs & interactive jobs are given higher priority than longer jobsProvide high throughput & good interactive response timeLonger jobs may have to wait an excessively long time
30 Last-in, first-out Good for transaction processing systems The device is given to the most recent user so there should be little arm movement for moving through a sequential filePossibility of starvation since a job may never regain the head of the line
31 Shortest Service Time First Select the disk I/O request that requires the least movement of the disk arm from its current positionAlways choose the minimum seek time
32 SCANArm moves in one direction only, satisfying all outstanding requests until it reaches the last track in that direction then the direction is reversedLOOK policy: reverse direction when there are no more requests in a direction
33 SCAN SCAN is biased against the area most recently traversed does not exploit localitySCAN favorsjobs whose requests are for tracks nearest to both innermost and outermost tracks andthe latest-arriving jobs
34 C-SCAN (Circular SCAN) Restricts scanning to one direction onlyWhen the last track has been visited in one direction, the arm is returned to the opposite end of the disk and the scan begins againReduces the maximum delay experienced by new requests
35 N-step-SCANWith SSTF, SCAN, C-SCAN, the arm may not move if processes monopolize the device by repeated requests to one track: arm stickinessSegments the disk request queue into subqueues of length NSubqueues are processed one at a time, using SCANNew requests are added to other queue when a queue is being processed
36 FSCANTwo subqueuesWhen a scan begins, all of the requests are in one of the queues, with the other emptyDuring the scan, all new requests are put into the other queueService of new requests is deferred until all of the old requests have been processed
37 Performance ComparedComparison of Disk Scheduling AlgorithmsT
38 Roadmap Operating System Design Issues I/O Buffering Disk Scheduling Disk Cache
39 Disk Cache Buffer in main memory for disk sectors Contains a copy of some of the sectorsWhen an I/O request is made for a particular sector, a check is made to determine if the sector is in the disk cacheIf so, the request is satisfied via the cacheIf not, the requested sector is read into the disk cache from the disk
40 Disk Cache Locality of reference When a block of data is fetched into the cache to satisfy a single I/O request, it is likely that there will be future references to that same blockOne design issue: replacement strategyWhen a new sector is brought into the disk cache, one of the existing blocks must be replaced
41 Least Recently Used (LRU) The block that has been in the cache the longest with no reference to it is replacedA stack of pointers reference the cacheMost recently referenced block is on the top of the stackWhen a block is referenced or brought into the cache, it is placed on the top of the stackThe block on the bottom of the stack is to be replaced
42 LRU Disk Cache Performance The miss ratio is, principally, a function of the size of the disk cache
43 Least Frequently Used (LFU) The block that has experienced the fewest references is replacedA counter is associated with each blockIncremented each time the block is accessedWhen replacement is required, the block with the smallest count is selected.Consider certain blocks are referenced repeatedly in short intervals due to locality, but are referenced relatively infrequently overall
44 Frequency-Based Replacement Blocks are logically organized in a stack, similar to LRUOn a cache hitOn a miss, the block with the smallest count that is not in the new section is chosen for replacement
45 Refined Frequency-Based Replacement Only blocks in the old section are eligible for replacementAllows relatively frequently referenced blocks a chance to build up their reference counts before becoming eligible for replacementSimulation studies indicate that this refined policy outperforms LRU and LFU
Your consent to our cookies if you continue to use this website.