Operating system buffering scheduling of hardware devices.
Citation preview
Chapter 11 I/O Management and Disk SchedulingNo Buffering
Without a buffer, OS directly accesses the device as and when it
needs
*
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
*
*
No Buffering
It is impossible to swap the process out completely because the
data area must be locked in main memory before I/O
Otherwise, data may be lost or single-process deadlock may
happen
*
I/O Buffering
*
disks and
USB drives
Transfers are made a block at a time
Can reference data by block number
*
*
terminals
printers
most other devices that are not secondary storage
Transfer information as a stream of bytes
*
*
Single 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
*
*
Provide a speedup
User process can be processing one block of data while the next
block is being read in
*
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
*
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 suits devices where a single keystroke may be
significant
Also sensors and controllers
*
*
Use two system buffers instead of one
*
*
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
*
*
Buffering smoothes out peaks in I/O demand
But with enough demand eventually all buffers become full and their
advantage is lost
*
*
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
*
*
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.
*
*
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 it takes for the
beginning of the sector to reach the head
*
*
Ta = Ts + 1 / (2r) + b / (rN)
where Ts = average seek time
b = no. of bytes to be transferred
N = no. of bytes on a track
r = rotation speed, in revolutions / sec.
*
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,
are
55, 58, 39, 18, 90, 160, 150, 38, 184.
*
*
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
processes
disk arm movement
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
*
*
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
*
*
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
*
*
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
*
*
does not exploit locality
SCAN favors
jobs whose requests are for tracks nearest to both innermost and
outermost tracks and
the latest-arriving jobs
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
*
*
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
*
*
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
*
*
T