1 chapter 11 i/o management and disk scheduling –operating system design issues –i/o buffering...
Post on 20-Dec-2015
231 views
TRANSCRIPT
![Page 1: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/1.jpg)
1
Chapter 11I/O Management and Disk Scheduling
– Operating System Design Issues
– I/O Buffering
– Disk Scheduling
– Disk Cache
![Page 2: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/2.jpg)
2
Goal: Generality
• For simplicity and freedom from error, it’s better to
handle all I/O devices in a uniform manner
• Due to the diversity of device characteristics, it is
difficult in practice to achieve true generality
• Use a hierarchical modular design of I/O functions
– Hide details of device I/O in lower-level routines
– User processes and upper levels of OS see devices in
terms of general functions, such as read, write, open,
close, lock, unlock
![Page 3: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/3.jpg)
3
Hierarchical design
• A hierarchical philosophy leads to organizing an OS into layers– Each layer performs a related subset of the
functions required of OS – Each layer relies on the next lower layer to
perform more primitive functions and to conceal the details of those functions
– Each layer provides services to the next higher layer
– Changes in one layer should not require changes in other layers
![Page 4: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/4.jpg)
4
Local peripheral device• Logical I/O:
– Deals with the device as a logical resource and is not concerned with the details of actually controlling the device
– Allows user processes to deal with the device in terms of a device identifier and simple commands such as open, close, read, write
• Device I/O:– Converts requested operations into sequence
of I/O instructions– Uses buffering techniques to improve
utilization
![Page 5: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/5.jpg)
5
Local peripheral device
• Scheduling and Control:
– Performs actual queuing / scheduling and
control operations
– Handles interrupts and collects and
reports I/O status
– Interacts with the I/O module and hence
the device hardware
![Page 6: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/6.jpg)
6
Goal: Efficiency
• Most I/O devices are extremely slow compared to main memory
I/O operations often form a bottleneck in a computing system
• Multiprogramming allows some processes to be waiting on I/O while another process is executing
![Page 7: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/7.jpg)
7
Goal: Efficiency
• Swapping brings in ready processes but this is an I/O operation itself
• A major effort in I/O design has been schemes for improving the efficiency of I/O– I/O buffering
– Disk scheduling
– Disk cache
![Page 8: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/8.jpg)
8
Roadmap
– Operating System Design Issues
– I/O Buffering
– Disk Scheduling
– Disk Cache
![Page 9: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/9.jpg)
9
I/O Buffering
• Processes 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)
• Problems– the program is hung up waiting for the
relatively slow I/O to complete– interferes with swapping decisions by OS
![Page 10: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/10.jpg)
10
I/O Buffering
– Data area within the address space of the user process must be locked in main memory during I/O
– Otherwise, data may be lost or single-process deadlock may happen
![Page 11: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/11.jpg)
11
I/O Buffering
• It 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.
![Page 12: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/12.jpg)
12
Block-oriented Buffering
• For block-oriented I/O devices such as – disks and – USB drives
• Information is stored in fixed sized blocks
• Transfers are made a block at a time• Can reference data by block number
![Page 13: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/13.jpg)
13
Stream-Oriented Buffering
• For stream-oriented I/O devices such as– terminals– printers– communication ports– mouse and other pointing devices, and – most other devices that are not secondary
storage
• Transfer information as a stream of bytes
![Page 14: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/14.jpg)
14
No Buffer
• Without a buffer, OS directly accesses the device as and when it needs
![Page 15: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/15.jpg)
15
Single Buffer
• OS assigns a buffer in the system portion of main memory for an I/O request
![Page 16: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/16.jpg)
16
Block OrientedSingle Buffer
• Input transfers are made to system buffer
• Block moved to user space when needed
• The next block is immediately requested, expecting that the block will eventually be needed– Read ahead or Anticipated Input
• A reasonable assumption as data is usually accessed sequentially
![Page 17: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/17.jpg)
17
Block OrientedSingle Buffer
• Provide a speedup
– User 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
![Page 18: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/18.jpg)
18
Block OrientedSingle Buffer
• Complicate the logic in OS– OS must keep track of the assignment of
system buffers to user processes
• Affect the swapping logic– Consider both the I/O operation and swapping
involve the same disk• Does it make sense to swap the process out after
the I/O operation finishes?
![Page 19: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/19.jpg)
19
Stream-orientedSingle Buffer
• Line-at-time or Byte-at-a-time
• Terminals often deal with one line at a time with carriage return signaling the end of the line– Also line printer
• Byte-at-a-time suites devices where a single keystroke may be significant– Also sensors and controllers
– Interaction between OS and user process follows the producer/consumer model
![Page 20: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/20.jpg)
20
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
![Page 21: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/21.jpg)
21
Circular Buffer
• More 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• Follows the bounded-buffer producer/consumer
model
![Page 22: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/22.jpg)
22
Buffer Limitations
• Buffering smoothes out peaks in I/O demand– But with enough demand eventually all buffers
become full and their advantage is lost
• In multiprogramming environment, buffering can increase the efficiency of OS and the performance of individual processes
![Page 23: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/23.jpg)
23
Roadmap
– Operating System Design Issues
– I/O Buffering
– Disk Scheduling
– Disk Cache
![Page 24: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/24.jpg)
24
Disk Performance Parameters
• Currently, disks are at least four orders of magnitude slower than main memory performance of disk storage subsystem is of
vital concern• A general timing diagram of disk I/O transfer is
shown here.
![Page 25: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/25.jpg)
25
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 or electronically selecting one head on a fixed-head system.
![Page 26: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/26.jpg)
26
Disk Performance Parameters
• Access Time is the sum of:– Seek time: The time it takes to position the
head at the desired track– Rotational delay or rotational latency: The
time its takes for the beginning of the sector to reach the head
• Transfer Time is the time taken to transfer the data (as the sector moves under the head)
![Page 27: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/27.jpg)
27
Disk Performance Parameters
• Total average access time Ta Ta = 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
![Page 28: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/28.jpg)
28
Disk SchedulingPolicies
• 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, are
– 55, 58, 39, 18, 90, 160, 150, 38, 184.
![Page 29: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/29.jpg)
29
First-in, first-out (FIFO)• Process requests sequentially• Fair to all processes• May have good performance if most requests
are to clustered file sectors• Approaches random scheduling in performance
if there are many processesdisk arm
movement
![Page 30: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/30.jpg)
30
Priority
• Control of the scheduling is outside the control of disk management software
• Goal is not to optimize disk use but to meet other objectives
• Often, short batch jobs & interactive jobs are given higher priority than longer jobs– Provide high throughput & good interactive
response time– Longer jobs may have to wait an excessively
long time
![Page 31: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/31.jpg)
31
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 file
• Possibility of starvation since a job may
never regain the head of the line
![Page 32: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/32.jpg)
32
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
![Page 33: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/33.jpg)
33
SCAN
• Arm moves in one direction only, satisfying all outstanding requests until it reaches the last track in that direction then the direction is reversed
• LOOK policy: reverse direction when there are no more requests in a direction
![Page 34: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/34.jpg)
34
SCAN
• SCAN is biased against the area most recently traversed
does not exploit locality
• SCAN favors
– jobs whose requests are for tracks nearest to both innermost and outermost tracks and
– the latest-arriving jobs
![Page 35: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/35.jpg)
35
C-SCAN (Circular 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
• Reduces the maximum delay experienced by new requests
![Page 36: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/36.jpg)
36
N-step-SCAN
• With SSTF, SCAN, C-SCAN, the arm may not move if processes monopolize the device by repeated requests to one track: arm stickiness
• Segments the disk request queue into subqueues of length N
• Subqueues are processed one at a time, using SCAN
• New requests are added to other queue when a queue is being processed
![Page 37: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/37.jpg)
37
FSCAN
• Two subqueues
• When a scan begins, all of the requests are in one of the queues, with the other empty
• During the scan, all new requests are put into the other queue• Service of new requests is deferred until all of
the old requests have been processed
![Page 38: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/38.jpg)
38
Performance Compared
Comparison of Disk Scheduling Algorithms
![Page 39: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/39.jpg)
39
Roadmap
– Operating System Design Issues
– I/O Buffering
– Disk Scheduling
– Disk Cache
![Page 40: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/40.jpg)
40
Disk Cache
• Buffer in main memory for disk sectors
• Contains a copy of some of the sectors
• When an I/O request is made for a particular sector, a check is made to determine if the sector is in the disk cache– If so, the request is satisfied via the cache
– If not, the requested sector is read into the disk cache from the disk
![Page 41: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/41.jpg)
41
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 block
• One design issue: replacement strategy– When a new sector is brought into the disk
cache, one of the existing blocks must be replaced
![Page 42: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/42.jpg)
42
Least Recently Used (LRU)
• The block that has been in the cache the longest with no reference to it is replaced
• A stack of pointers reference the cache– 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– The block on the bottom of the stack is to be
replaced
![Page 43: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/43.jpg)
43
LRU Disk Cache Performance
• The miss ratio is, principally, a function of the size of the disk cache
![Page 44: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/44.jpg)
44
Least Frequently Used (LFU)
• The block that has experienced the fewest references is replaced
• A counter is associated with each block– Incremented each time the block is accessed
• When 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
![Page 45: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/45.jpg)
45
Frequency-Based Replacement
• Blocks are logically organized in a stack, similar to LRU
On a cache hit
On a miss, the block with the smallest count that is not in the new section is chosen for replacement
![Page 46: 1 Chapter 11 I/O Management and Disk Scheduling –Operating System Design Issues –I/O Buffering –Disk Scheduling –Disk Cache](https://reader034.vdocuments.mx/reader034/viewer/2022042522/56649d4b5503460f94a296e0/html5/thumbnails/46.jpg)
46
Refined Frequency-Based Replacement
• Only blocks in the old section are eligible for replacement
• Allows relatively frequently referenced blocks a chance to build up their reference counts before becoming eligible for replacement
• Simulation studies indicate that this refined policy outperforms LRU and LFU