Download I/O Management & Disk Scheduling: Categories, Differences, Techniques, Performance (80 cha and more Slides Computer Science in PDF only on Docsity! 1 I/O Management and Disk Scheduling Chapter 11 Docsity.com 2 Categories of I/O Devices • Human readable – Used to communicate with the user – Printers – Video display terminals • Display • Keyboard • Mouse Docsity.com 5 Differences in I/O Devices • Data rate – May be differences of several orders of magnitude between the data transfer rates Docsity.com
Gigabit Ethernet
Graphies display
Hard disk
Ethernet
Optical disk
Scanner
Laser printer
Floppy disk
Modem
Mouse
Keyboard
1
S
! 10% 105 104 108 10° 107 108 109
Data Rate (bps)
Figure 11.1 Typical I/O Device Data Rates
6
Docsity.com
7 Differences in I/O Devices • Application – Disk used to store files requires file management software – Disk used to store virtual memory pages needs special hardware and software to support it – Terminal used by system administrator may have a higher priority Docsity.com 10 Performing I/O • 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 Docsity.com Relationship Among Techniques
Table 11.1 VO Techniques
No Interrupts
Use of Interrupts
V/O-to-memory transfer
through processor
Programmed 1/0
Tnterrupt-driven I/O
Direct I/O-to-memory
transfer
Direct memory access (DMA)
11
Docsity.com
12 Evolution of the I/O Function • 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 Docsity.com 15 Direct Memory Access • Processor delegates I/O operation to the DMA module • DMA module transfers data directly to or form memory • When complete DMA module sends an interrupt signal to the processor Docsity.com DMA
» Data
Count
Data Lines = Data
Register
») Address
Address Lines ¢<————_;—__ Register
DMA Request ¢
DMA Acknowledge | Control
Interrupt ¢ Logic
Read :——
Write —
Figure 11.2. Typical DMA Block Diagram
16
Docsity.com
DMA Configurations
Processor
DMA
vo
vo
Memory
(a) Single-bus, detached DMA
Processor
DMA
DMA
Memory
vo
vO
vO
(b) Single-bus, Integrated DMA-/O
17
Docsity.com
20 Operating System Design Issues • Generality – Desirable to handle all I/O devices in a uniform manner – Hide 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 Docsity.com Processes:
Directory
Management
ommunicatior File
|
Ff
é
ei
Scheduling Scheduling Scheduling
& Control & Control
{}
Z
(a) Local peripheral device {b) Communications port {c) File system
Figure 11.4 A Model of I/O Organization mT
Docsity.com
22 I/O Buffering • Reasons for buffering – Processes must wait for I/O to complete before proceeding – Certain pages must remain in main memory during I/O Docsity.com 25 Single Buffer • 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 Docsity.com 26 Single Buffer • 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 Docsity.com I/O Buffering
Operating System User Process
1/0 Device In
(a) No buffering
Operating System User Process
V/O Device In Move
(b) Single buffering
27
Docsity.com
30 Disk Performance Parameters • To read or write, the disk head must be positioned at the desired track and at the beginning of the desired sector • Seek time – Time it takes to position the head at the desired track • Rotational delay or rotational latency – Time its takes for the beginning of the sector to reach the head Docsity.com Timing of a Disk I/O Transfer
wa i for ut it fon Seek Rotational Data
Delay Transfer
rT LTTE sostacceaae re socacsnaae +—_-
Device Bus’ >
Figure 11.6 Timing of a Disk /O Transfer
31
Docsity.com
32 Disk Performance Parameters • Access time – Sum of seek time and rotational delay – The time it takes to get in position to read or write • Data transfer occurs as the sector moves under the head Docsity.com 35 Disk Scheduling Policies • 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 Docsity.com 36 Disk Scheduling Policies • 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 – Possibility of starvation since a job may never regain the head of the line Docsity.com 37 Disk Scheduling Policies • 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 Docsity.com 40 Disk Scheduling Policies • N-step-SCAN – Segments the disk request queue into subqueues of length N – Subqueues are processed 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 requests Docsity.com Disk Scheduling Algorithms
(a) FIFO
(starting at track 100)
(b) SSTF
(starting at track 100)
(<) SCAN
(starting at track 100. in the
direction of increasing track
Table 11.2, Comparison of Disk Scheduling Algorithms
(@ C-SCAN
(starting at track 100. in the
direction of increasing track
number) number)
Next track Number of Next track Number of Next track Number of Next track Number of
accessed tracks accessed tracks accessed tracks accessed tracks
traversed traversed traversed traversed
55 45 90 10 150 50 150 50
58 3 58 32 160 10 160 10
39 19 55 3 184 24 184 24
18 21 39 16 90 o4 18 166.
90 72 38 1 38 32 38 20
160 70 18 20 55 3 39 1
150 10 150 132 39 16 55 16
38 112 160 10 38 1 58 3
184 146 184 24 1g 20 90 32
Average seek 55.3 Average seek 275 Average seek 27.8 Average seek 35.8
length length length length
41
Docsity.com
42 RAID • Redundant Array of Independent Disks • Set of physical disk drives viewed by the operating system as a single logical drive • Data are distributed across the physical drives of an array • Redundant disk capacity is used to store parity information Docsity.com RAID 2 (redundancy through
Hamming code)
by by by by Toth) thy f(b)
(c) RAID 2 (redundancy through Hamming code)
RAID 3 (bit-interleaved
parity)
a
1 toy hoy toy soy 1
1 a toe ‘oo too ‘loo
(d) RAID 3 (bit-interleaved parity)
RAID 4 (block-level parity)
block 2 block 3
block 6 block 7
P(0-3)
P(a-7)
P(8-11)
P(12-15)
block 10 block 11
block 14 block 15
(e) RAID 4 (block-level parity)
47
Docsity.com
50 Disk Cache • Buffer in main memory for disk sectors • Contains a copy of some of the sectors on the disk Docsity.com 51 Least 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 Docsity.com 52 Least Recently Used • The 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 Docsity.com Disk cache miss rate (%)
be VAX UNIX
o-
wo
~~
» re
ee
-----.
104 Steen
ween, IBM SVS
Steen eee eeeee
ween eee ene ee ne,
0
! ! :
0 5 10 5 * * °
‘Cache size (megabytes)
Figure 11.10 Some Disk Cache Performance Results Using LRU
55
Docsity.com
IBM YM
Disk cache miss rate (%})
IBM MVS
VAX UNIX
T T T T T T
oO a 10 15 20 25 30
Cache size (megabytes)
Figure 11.11 Disk Cache Performance Using Frequency-Based Replacement [ROBI90]
e .
Docsity.com
57 UNIX SCR4 I/O • Each individual device is associated with a special file • Two types of I/O – Buffered – Unbuffered Docsity.com 60 Linux I/O • Deadline scheduler – Uses three queues • Incoming requests • Read requests go to the tail of a FIFO queue • Write requests go to the tail of a FIFO queue – Each request has an expiration time Docsity.com Linux I/O
Sorted (elevator) queue
Read FIFO queue
Write FIFO queue
Figure 11.14 The Linux Deadline I/O Scheduler
61
Docsity.com
62 Linux I/O • Anticipatory I/O scheduler – Delay a short period of time after satisfying a read request to see if a new nearby request can be made Docsity.com