Title: I/O Management and Disk Scheduling
1Lecture 10
- I/O Management and Disk Scheduling
2I/O ?? ?? (1)
- Human readable
- ??? ???? ???? ?? ???? ??
- ???
- ??? ????? ???
- ????? ??
- ???
- ???
3I/O ?? ?? (2)
- Machine readable
- ?? ?? ??? ???? ?? ???? ??? ??
- ??? ? ??? ????
- I/O Controllers
- Sensors
- Actuators
4I/O ?? ?? (3)
- Communication
- ?? ??? ???? ?? ???? ??
- Digital line drivers
- Modems
5I/O ??? ??? (1)
- Data rate
- ??? ?? ?? I/O ???? ???? ?? ?? ??
- I/O ???? ??? ?? ??? ? ??? ?? ? ??? ? ? ??
6(No Transcript)
7I/O ??? ??? (2)
- Application(??)
- ??? ???? ???? ????? ???? ?? ?? ?????? ??
- ?? ??? ???? ???? ????? ???? ??? ????? ?????? ??
- ??? ???? ???? ???(??)? ?? ????? ? ?? ?? ??? ???
8I/O ??? ??? (3)
- Complexity of control
- Unit of transfer
- Data may be transferred as a stream of bytes for
a terminal or in larger blocks for a disk - Data representation
- Encoding schemes
- Error conditions
- Devices respond to errors differently
9I/O ?? ?? (1)
- Programmed I/O
- Process is busy-waiting for the operation to
complete - Interrupt-driven I/O
- I/O command is issued
- Processor continues executing instructions
- I/O module sends an interrupt when done
- Direct Memory Access (DMA)
- DMA module controls exchange of data between main
memory and the I/O device - Processor interrupted only after entire block has
been transferred
10I/O ?? ?? (2)
???? ?? ???? ??
????? ?? I/O? ???? ?? Programmed-I/O Interrupt-driven I/O
I/O? ???? ?? ?? DMA
11I/O ??? ?? ?? (1)
- Processor directly controls a peripheral device
- Controller or I/O module is added
- Processor uses programmed I/O without interrupts
- Processor does not need to handle details of
external devices - Controller or I/O module with interrupts
- Processor does not spend time waiting for an I/O
operation to be performed - Direct Memory Access
- Blocks of data are moved into memory without
involving the processor - Processor involved at beginning and end only
12I/O ??? ?? ?? (2)
- I/O module is a separate processor
- I/O Channel
- I/O processor
- I/O module has its own local memory
- Its a computer in its own right
13DMA(Direct Memory Access) (1)
- DMA(Direct Memory Access)
- ?????? I/O ?? ??? ?? ???? ??
- DMA ??? I/O? ???? ?? ??? ??? ????
- ??? ??? ?? ???? ???? ???? ?? CPU??? ??? ??? ????
- Cycle Stealing(??? ???)
- ????? ??? ???? ?? ?? ??? ??
- ????? ????? ??? ?? ????? ?? ??? ?? ???? ???
- No interrupts occur
- ???? ??? ?? ????? ??
14DMA(Direct Memory Access) (2)
15DMA(Direct Memory Access) (3)
- Cycle stealing? CPU? ?? ??? ?????
16DMA(Direct Memory Access) (4)
- DMA ?? ??
- DMA ??? I/O ??? ??? ??? ???? ??
- ??-DMA ??(a)
- ??? ?? ??? ???? ? ??? ??? ???? ?? ? ?? ??? ?? ???
?? - DMA? I/O ??? ???? ??
- ??-DMA ??(b)
- DMA ??? I/O ????? ??? ??? ?? ? ???? ?? ??? ?? ??
?? - DMA ??? I/O ????? ?? ??
- ??? I/O ??? ???? DMA ??? ???? ??
- ??-DMA ??(c)
- DMA ??? I/O ????? ??? ??? ??? ??? ???? ??
17DMA(Direct Memory Access) (5)
18DMA(Direct Memory Access) (6)
19DMA(Direct Memory Access) (7)
20I/O ?? ?? ?? (1)
- ???(Efficiency)
- ???? I/O ??? ????? ? CPU? ???? ??? ?? ???
- ?? ??? ?? ????? ??????? ??? ??
- ?? ?????? I/O ??? ???? ??? ?? ????? ????? ??
- ??? I/O ??? ??? CPU ??? ???? ?? ????? ?? ???
????? ???? ???(swapping)? ???? ??? ?? - Swapping? I/O? ??
- ??? ?? ??? ???? ???? I/O? ??
21I/O ?? ?? ?? (2)
- ???(Generality)
- ???? ??? ?? ??? ?? ??? ???? ?? I/O ??? ??? ??
????? - ??? ??? ???? ?? ??? ???? ???? ???? ????? ???
- ??? ?? ???
- ????? ?? ????? ???? ???? ??? ??
- ????? ?? ????? I/O ??? ??? ???? ??? ?????? ?? ???
I/O ??? ??? ??? ?? ? ??? ??
22I/O ?? ?? ?? (3)
- I/O ??? ??? ??
- ??? ?? ??? ??? I/O ??? ??
- ?? ??? I/O ??? ?? ???? ??? ??
- ?? ??? ???? I/O ?? ?? ??? ?? ?? ??? ???? ??
- ??? ?????? ?????? ?? ??? ??? ?? ?? ??? ??? ???
??? ?? - I/O ??? ??? ?? ?
23(No Transcript)
24I/O Buffering (1)
- I/O ???? ???
- ????? ????? ?? I/O? ??? ??? ?? ??? ??
- ??? ???? ?? ???? ????? I/O ?? ??? ??? ? ??
- I/O? ???? ?? ????? ???? ?? ????? ???? ? ??
- ?? ???? ????? ??
25I/O Buffering (2)
- I/O ???? ??? ??? ?? ??? ??
- ?? ??(Block-oriented) I/O ??
- ?? ??? ??? ?? ??? ??? ??
- ??? ??? ??? ??
- ??? ??, ??? ?? ?
- ??? ??(Stream-oriented) I/O ??
- ??? ??? ??? ???? ??
- ???, ???, ?? ??, ??? ?
26I/O Buffering (3)
27I/O Buffering (4)
28Single Buffer (1)
- ????? I/O ??? ?? ?????? ??? ??? ??? ??? ????
- ?? ?? ??
- ?? ??? ??? ??? ?????
- ????? ??? ?? ???? ??? ???? ????? ????? ?? ??? ??
- Read ahead or Anticipated input
- ????? ?? ??? ???? ?? ??? ??? ??
- ??? ?????? ??? ???? ????? ??? ???? ??? ????? ????
? ?? - ????? ????? ??? ??? ???? ?? ??? ?????? ?? ??? ????
29Single Buffer (2)
- ??? ?? ??
- ??? ??? ???? ? ???? ??
- ???? ?? ??? ??? ??? ????? ? ??? ??
- ??? ??? ?? ??? ??
- ????? ? ??? ???? ??? ??? ?? ??
30Double Buffer
- ? ?? ??? ??? ??
- ????? ??? ??? ???? ??? ??? ????? ?? ??? ???? ????
?? - ?? ????? ?? ??
31Circular Buffer
- ??? ??? ???? ? ? ??? ??? ???? ??
- I/O ??? ?? ?? ????? ???? ?? ?? ???? ??
- ?? ??? ? ??? ??? ?? ??? ??
- I/O ??? ????? ??? ??? ??? ??
32??? ??
- ??? ??
- ???? ?? ?? ??
- ??? ????? ??? I/O ???? ??? ?? ??? ?? ? ??
- CPU ?? ?????? ???? ??? ??? ?? ??
- ?? ??? ?? ??? ?? ??? ?? ??? ???
33Disk Data Layout
Sectors
Tracks
Inter-sector gap
Inter-track gap
34Disk Layout Using Constant Angular Velocity
Track 0, Sector 0
Track 2, Sector 7
35??? ?? ?? (1)
- ??? ??? ??
- ??? ???? ???? ??? ??? ??? ???? ???? ??? ??? ??
??? ???? - ?? ??? ?? ??? ??? ?? ???? ?? ????
36??? ?? ?? (2)
- ?? ??(Seek time)
- ??? ??? ??? ????? ??? ??
- ??? ?????? ????? ???? ??
- ?? ?? ??(Rotational delay or rotational latency)
- ??? ??? ??? ???? ??? ????? ??? ??
- ??? ?? ??(Access time)
- ?? ??? ?? ?? ??? ?
- ??? ???? ?? ??? ??? ????? ??? ??
37Timing of a Disk I/O Transfer
38??? ???? ?? (1)
- ?? ??(Seek time)? ??? ??? ?? ??? ??
- ??? ???? ?? ??? ??? ??? ??
- ??? ??? ?? ??? ??? ?? ?? ??? ????? ??? ??? ??? ??
- ??? ??? ????? ???? ????? (random scheduling) ???
??? ??? ?? ??? ?? ?? - ??? ??? ???? ?? ??? ????? ??
39??? ???? ?? (2)
- ????(First-in, first-out FIFO)
- ????? ??? ??? ??? ???? ??
- ?? ????? ?? ????
- ??? ??? ??? ?? ???? ?? ?? ???? ??? ?????
40??? ???? ?? (3)
- ?? ??(Priority)
- ???? ??? ??? ??? ????? ?? ??? ????? ?? ??? ????
?? - ?? ??? ?? ???? ???? ??? ??? ?? ?? ??? ??
- ? ?? ?? ??? ??
41??? ???? ?? (4)
- ?? ??(Last-in, first-out LIFO)
- ?? ??? ??? ??? ?? ??
- ???? ?? ????? ?? ??? ??
- ????? ???? ?????? ??? ?? ??? ??? ??
- ???? ????? ?? ??? ?? ??
- ? ??? ??? ??? ?? ??? ?? ?? ??? ??? ??? ?? ??? ???
???? ??
42??? ???? ?? (5)
- Shortest Service Time First(SSTF)
- ??? ??? ?? ????? ??? ?? ???? ????? ??? ??? ??? ??
?? - ?? ??? ?? ??? ???? ??? ??? ??
43??? ???? ?? (6)
- SCAN
- ????, LIFO, SSTF ?? ???? ????? ??? ???? ??
- ?? ???? ??? ??? ??? ???? ?? ?????? ?? ???? ?? ???
??? ? ?? - ??? ??? ?? ? ???? ????? ?? ??? ???? ??? ??? ???
????? ???? ??? ??? ?? ??? ? ??? ???? ?? ??? ????
???? ?? - ? ???? ???? ??? ?? ???? ????? ?????
- ?? ???? ??? ??? ???? ??? ?? ?? ??? ??? ??
44??? ???? ?? (7)
- C-SCAN
- SCAN ???? ??? ??? ?? ?? ????? ????? ?????? ??
- ? ???? ????? ??? ??? ??? ??? ???? ?? ??? ???? ??
?? ???? ???? - SCAN ??? ?? ? ??? ???? ??? ?? ???? ???? ??? ????
??
45??? ???? ?? (8)
- SSTF, SCAN, C-SCAN ????? ? ??(Arm stickness)
??? ??? ? ?? - ??? ???? ? ??? ?? ?? ???? ????? ??? ?? ?? ?? ????
?? ? ?? - N-step-SCAN
- Segments the disk request queue into subqueues of
length N - Subqueues are process one at a time, using SCAN
- New requests added to other queue when queue is
processed - FSCAN
- Two queues
- One queue is empty for new request
46??? ???? ???? ??(1)
47??? ???? ???? ??(2)
- ??? ???? ????? ?? ??
- ?? ?? ?? ??
- ???? 200 ?? ???? ??
- ??? ?? ?? ??? ???? ??
- ?? ??? 55, 58, 39, 18, 90, 160, 150, 38, 184 ???
?? - ?? ???? ????
- FIFO
- SSTF
- SCAN
- C-SCAN
48??? ???? ???? ??(3)
49??? ???? ???? ??(4)
50RAID 0 (non-redundant)
51(No Transcript)
52RAID 1 (mirrored)
53RAID 2 (redundancy through Hamming code)
54RAID 3 (bit-interleaved parity)
55RAID 4 (block-level parity)
56RAID 5 (block-level distributed parity)
57RAID 6 (dual redundancy)
58Disk Cache
- Buffer in main memory for disk sectors
- Contains a copy of some of the sectors on the
disk
59Least Recently Used
- The 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
60Least Recently Used
- The block on the bottom of the stack is removed
when a new block is brought in - Blocks dont actually move around in main memory
- A stack of pointers is used
61Least Frequently Used
- The 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
62UNIX SVR4 I/O
63Windows 2000 I/O