OS Chap 5 - Eng - Hust Theme
OS Chap 5 - Eng - Hust Theme
• Đỗ Quốc Huy
• [email protected]
• Department of Computer Science
• School of Information and Communication Technology
Chapter 5 I/O Management
• Introduction
IO device
• Diversity, many kinds, different types
• Engineering perspective: device with processor, motor, and other parts
• Programming perspective: Interface like software to receive, executive
command and return result
• Catergorize
• Block device (disk, magnetic tape)
• Information is stored with fixed size and private address
• Possible to read/write a block independent from other
• Operation to locate information exist (seek)
• Character device (printer, keyboard, mouse,..)
• Accept a stream of chracter, without block structure
• No information localization operation
• Other type: Clock
1. General management principle
1.1 Introduction
Controller device I
⚫Introduction
Interrupt definition
Classification
• Based on Source
• Internal interrupt
• External interrupt
• Based on device
• Hard
• Soft
• Based on handling ability
• maskable
• unmask able
• Based on interrupt moment
• Request
• Report
1. General management principle
1.2 Interrupt and Interrupt handle
Interrupt handle
⚫Buffer
⚫SPOOL mechanism
2. System I/O service
2.1. Buffer
General conception
Buffer classification I
• Input buffer
• Can perform data access command
• Example: read data from disk
• Output buffer
• Information is putted into buffer, when buffer’s full, buffer
content is then written to device
2. System I/O service
2.1. Buffer
Buffer classification II
• Buffer attached to device
• Constructed when open device/file
• Serve device only, cleared when device is close
• Good when devices have different physical record’s structures
• Buffer attached to system
• Constructed when the system start, not attached to a specific
device
• Exist during system working process
• Open file/device ⇒ attach to already available buffer
• Close device/file ⇒ buffer returned to system
• Good for devices have same physical record’s structure
2. System I/O service
2.1. Buffer
Buffer organization
• Value buffer
• Input buffer
• Output buffer
• Processing buffer
• Circular buffer
• Input buffer
• Output buffer
• Processing buffer
2. System I/O service
2.1. Buffer
Buffer organization
• Value buffer
• Input buffer
• Output buffer read(f,a);
read(f,a);
Gi n
AM ị
át
biế
r
a
2. System I/O service
2.1. Buffer
Buffer organization
• Processing buffer
Đị ron ệm
AM
ac
ph
t read(f,a);
hỉ g
òn
biế
gđ
n
a
2. System I/O service
2.1. Buffer
Buffer organization
• Circular buffer
• Input buffer
• Output buffer
• Processing buffer Write
Read
Process
2. System I/O service
2.2 Spool
⚫Buffer
⚫SPOOL mechanism
2. System I/O service
2.2 Spool
SPOOL:IO example
Chapter 5 I/O Management
⚫Disk structure
⚫Disk accessing scheduling
3. Disk I/O device
3.1 Disk structure
Structure
⚫Disk structure
⚫Disk accessing scheduling
3. Disk I/O device
3.2 Disk accessing scheduling
Algorithm
• Assumption
• Accessing requests 98, 183, 37, 122, 14, 124, 65, 67
• Header current position at cylinder 53
3. Disk I/O device
3.2 Disk accessing scheduling
FCFS
Access follow the request order ⇒Not effective
Accessing requests 98, 183, 37, 122, 14, 124, 65, 67
45
85
146
85
108
Total: 630
110
59
2
3. Disk I/O device
3.2 Disk accessing scheduling
SSTF
Select access has smallest seek time from current position ⇒A
request may wait forever if new appearing requests closer to header (similar to SJF)
Accessing requests 98, 183, 37, 122, 14, 124, 65, 67
12
2
30
23
84
24 Total: 236
2
59
3. Disk I/O device
3.2 Disk accessing scheduling
SCAN
Header move from outer most cylinder to innermost cylinder and return. Serve
request met on the way
15
Header is moving to cylinder 0
23
14
65 2
31
24 Total: 235
2
59
3. Disk I/O device
3.2 Disk accessing scheduling
C-SCAN
Principle: Treat cylinders like a circular linked list: Outer most Cylinder connect
with innermost cylinder
C-SCAN
Header move from outermost cylinder to innermost cylinder and return. Serve
request met on the way
LOOK/ C-LOOK
SCAN/C-SCAN’s version: Header does not move to outermost/innermost cylinders,
only to farthest request at 2 sides and return
Conclusion
Conclusion
• Disk access requests are affected by disk allocation methods for files
• Continuous Allocation: making requests to access adjacent to each
other
• Link/index Allocation: can include widely split blocks on disk
• Both SSTF and LOOK can be reasonable choices for the default algorithm