Download presentation
Presentation is loading. Please wait.
Published bySonia Blizzard Modified over 10 years ago
2
Chapter 4 Device Management and Disk Scheduling
3
DEVICE MANAGEMENT Content I/O device overview I/O device overview I/O organization and architecture I/O organization and architecture I/O buffering I/O buffering Disk scheduling Disk scheduling RAID RAID Notes: Difficult to develop a general, consistent solution. Just a generally discuss. Notes: Difficult to develop a general, consistent solution. Just a generally discuss.
4
DEVICE MANAGEMENT 4.1 I/O Devices (P452) Three categories: Human Readable Devices Human Readable Devices ٭Such as Keyboard, Mouse, Display, Printer and so on; Machine Readable Devices Machine Readable Devices ٭Such as Actuator, Controller, Sensor, Tape Drive, Disk Drive and so on; Communication Devices Communication Devices ٭Such as Modem, Network Adapter and so on.
5
DEVICE MANAGEMENT Classify There are many sorting standard. E.g. data rates There are many sorting standard. E.g. data rates
6
DEVICE MANAGEMENT Data Rates of Devices
7
DEVICE MANAGEMENT Differences in I/O Devices Application 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 than an ordinary user
8
DEVICE MANAGEMENT Differences in I/O Devices Complexity of control Complexity of control Unit of transfer Unit of transfer ٭Data may be transferred as a stream of bytes for a terminal or in larger blocks for a disk Data representation Data representation ٭Encoding schemes Error conditions Error conditions ٭Devices respond to errors differently
9
DEVICE MANAGEMENT 4.2 Techniques for Performing I/O (p453 11.2) 4.2 Techniques for Performing I/O (p453 11.2) Cyclic Test /Programmed Cyclic Test /Programmed Interrupt-Driven Interrupt-Driven DMA Control DMA Control
10
DEVICE MANAGEMENT Programmed I/O --P29. I/O module performs the action, not the processor I/O module performs the action, not the processor Sets appropriate bits in the I/O status register Sets appropriate bits in the I/O status register No interrupts occur No interrupts occur Processor checks status until operation is complete Processor checks status until operation is complete Busy-waits Busy-waits
11
DEVICE MANAGEMENT Interrupt-Driven I/O Processor is interrupted when I/O module ready to exchange data Processor is interrupted when I/O module ready to exchange data Processor is free to do other work Processor is free to do other work No needless waiting No needless waiting Consumes a lot of processor time because every word read or written passes through the processor Consumes a lot of processor time because every word read or written passes through the processor
12
DEVICE MANAGEMENT Direct Memory Access Transfers a block of data directly to or from memory Transfers a block of data directly to or from memory An interrupt is sent when the task is complete An interrupt is sent when the task is complete The processor is only involved at the beginning and end of the transfer The processor is only involved at the beginning and end of the transfer
13
DEVICE MANAGEMENT Evolution of the I/O Function Processor directly controls a peripheral device Processor directly controls a peripheral device Controller or I/O module is added Controller or I/O module is added ٭Processor uses programmed I/O without interrupts ٭Processor does not need to handle details of external devices
14
DEVICE MANAGEMENT Evolution of the I/O Function Controller or I/O module with interrupts Controller or I/O module with interrupts ٭Processor does not spend time waiting for an I/O operation to be performed Direct Memory Access Direct Memory Access ٭Blocks of data are moved into memory without involving the processor ٭Processor involved at beginning and end only
15
DEVICE MANAGEMENT Evolution of the I/O Function I/O channel I/O channel ٭I/O module is a separate processor. Its with a specialized instruction set tailored( ) for I/O. I/O processor I/O processor ٭I/O module has its own local memory ٭Its a computer in its own right
16
DEVICE MANAGEMENT Direct Memory Access Takes control of the system from the CPU to transfer data to and from memory over the system bus Takes control of the system from the CPU to transfer data to and from memory over the system bus Cycle stealing is used to transfer data on the system bus Cycle stealing is used to transfer data on the system bus The instruction cycle is suspended so data can be transferred The instruction cycle is suspended so data can be transferred The CPU pauses one bus cycle The CPU pauses one bus cycle No interrupts occur while cycle stealing No interrupts occur while cycle stealing ٭Do not save context
17
DEVICE MANAGEMENT Direct Memory Access
18
DEVICE MANAGEMENT DMA The Starting location in memory to read from or write to, communicated on the data lines and stored by the DMA module in its address register. The Starting location in memory to read from or write to, communicated on the data lines and stored by the DMA module in its address register. The number of words to be read or written, again communicated via the data lines and stored in the data count register. The number of words to be read or written, again communicated via the data lines and stored in the data count register.
19
DEVICE MANAGEMENT DMA and Interrupt Breakpoint The processor is suspended just before it needs to use the bus. The DMA unit then transfers one word and returns control to the processor. The processor is suspended just before it needs to use the bus. The DMA unit then transfers one word and returns control to the processor. Cycle stealing causes the CPU to execute more slowly. Cycle stealing causes the CPU to execute more slowly.
20
DEVICE MANAGEMENT DMA and Interrupt Breakpoint
21
DEVICE MANAGEMENT DMA Number of required bus cycles can be cut by integrating the DMA and I/O functions Number of required bus cycles can be cut by integrating the DMA and I/O functions Path between DMA module and I/O module that does not include the system bus Path between DMA module and I/O module that does not include the system bus
22
DEVICE MANAGEMENT DMA
23
DMA
24
DMA
25
4.3 Operating System Design Issues Efficiency Efficiency ٭Most I/O devices extremely slow compared to main memory ٭Use of multiprogramming allows for some processes to be waiting on I/O while another process executes ٭I/O cannot keep up with processor speed ٭Swapping is used to bring in additional ready processes which is an I/O operation ٭Thus, a major effort in I/O design has been schemes for improving the efficiency of I/O. e.g. disk I/O
26
DEVICE MANAGEMENT Operating System Design Issues Generality 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
27
Struct general_op{ int (*read)(…) int (*write)(…) };driver1: Struct general_op dev_op={ dev1_read, dev1_write dev1_write};driver2: Struct general_op dev_op={ dev2_read, dev2_write dev2_write};Gen_read(fd,…) {dev_op=map(fd); dev_op->read(…);}
28
DEVICE MANAGEMENT Logical Structure of the I/O Function (e.g. Hierarchical p458) Logical I/O Logical I/O ٭Is concerned with general I/O function, and is not concerned with the detail of actually controlling. E.g. read, write… Device I/O Device I/O ٭Implement I/O instructions, channel commands, and controller orders. May use buffering techniques.
29
DEVICE MANAGEMENT Logical Structure of the I/O Function Scheduling and Control Scheduling and Control ٭This is the level of software that actually interacts with the I/O module and the device hardware.
30
DEVICE MANAGEMENT
31
4.4 I/O Buffering(p460) 4.4 I/O Buffering(p460) Reasons for buffering Reasons for buffering ٭Processes must wait for I/O to complete before next proceeding. E.g: write to device (busy waiting or suspension on an interrupt) ٭Certain pages of the I/O request process must remain in main memory during I/O. ٭Single-process deadlock
32
DEVICE MANAGEMENT I/O Buffering Block-oriented Block-oriented ٭Information is stored in fixed sized blocks ٭Transfers are made a block at a time ٭Used for disks and tapes Stream-oriented Stream-oriented ٭Transfer information as a stream of bytes ٭Used for terminals, printers, communication ports, mouse, and most other devices that are not secondary storage
33
DEVICE MANAGEMENT Single Buffer Operating system assigns a buffer in the system portion of main memory for an I/O request Operating system assigns a buffer in the system portion of main memory for an I/O request Block-oriented Block-oriented ٭Input transfers made to buffer ٭Block moved to user space when needed ٭Another block is moved into the buffer Read aheadRead ahead
34
DEVICE MANAGEMENT
35
Single Buffer Block-oriented 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
36
DEVICE MANAGEMENT Single Buffer Stream-oriented 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.
37
DEVICE MANAGEMENT Single Buffer Performance comparison with no buffering Performance comparison with no buffering ٭T: the time to input a block ٭C: the time to computation ٭M: the time to move data ٭Max [C,T]+M and T+C
38
DEVICE MANAGEMENT Double Buffer Use two system buffers instead of one. Use two system buffers instead of one. A process can transfer data to or from one buffer while the operating system empties or fills the other buffer. A process can transfer data to or from one buffer while the operating system empties or fills the other buffer. Performance: max(C,T). Performance: max(C,T).
39
DEVICE MANAGEMENT Circular Buffer More than two buffers are used. More than two buffers are used. Each individual buffer is one unit in a circular buffer. Each individual buffer is one unit in a circular buffer. Used when I/O operation must keep up with process. Used when I/O operation must keep up with process.
40
DEVICE MANAGEMENT
41
Disk and Disk Scheduling(p463) The speed of processors and main memory has far outstripped that for disk access. The speed of processors and main memory has far outstripped that for disk access. The performance of disk storage subsystem is of vital concern. The performance of disk storage subsystem is of vital concern. How to improve the performance of disk? How to improve the performance of disk? ٭General methods ٭Special methods
42
DEVICE MANAGEMENT Disk Structure Headers Headers Cylinders Cylinders Tracks Tracks Sectors Sectors Capability=headers*cylinders*sectors*byte per sector Capability=headers*cylinders*sectors*byte per sector
43
DEVICE MANAGEMENT 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 To read or write, the disk head must be positioned at the desired track and at the beginning of the desired sector Seek time Seek time ٭movable-head system or fixed-head system ٭Time it takes to position the head at the desired track Rotational delay or rotational latency Rotational delay or rotational latency ٭Time its takes for the beginning of the sector to reach the head
44
DEVICE MANAGEMENT Disk Performance Parameters Data transfer time Data transfer time Wait for device or channel Wait for device or channel
45
DEVICE MANAGEMENT RPS (Rotational Positional Sensing) When seek command has been issued, the channel is released to handle other I/O operations. When seek command has been issued, the channel is released to handle other I/O operations. RPS miss. Must rotate again and reconnect again. RPS miss. Must rotate again and reconnect again.
46
DEVICE MANAGEMENT Seek Time Ts m×n s n=number of tracks traversed m=constant that depends on the disk drive s=startup time
47
DEVICE MANAGEMENT Rotational Delay Tr 1/(2r) r=rotation speed, in revolutions per second Example: r=3600rpm, Tr=1/120=8.3ms r=300rpm, Tr=1/10=100ms
48
DEVICE MANAGEMENT Transfer Time T b (r×N) b=number of bytes to be transferred N=number of bytes on a track r=rotation speed,in revolutions per second
49
DEVICE MANAGEMENT Total Average Access Time Ta=Ts+Tr+T
50
DEVICE MANAGEMENT A Timing Comparison Seek time: 20ms Seek time: 20ms Transfer rate: 1MB/s Transfer rate: 1MB/s r=3600rpm r=3600rpm 512byte per sector 512byte per sector 32 sector per track 32 sector per track Suppose to read 128k data Suppose to read 128k data
51
DEVICE MANAGEMENT A Timing Comparison 60*16k=960k<1MB/s 60*16k=960k<1MB/s Sequential organization Sequential organization (20 8.3 16.7) (8.3 16.7)×7 220(ms) Randomly organization Randomly organization (20 8.3 0.5)×256 7373(ms)
52
DEVICE MANAGEMENT A Timing Comparison It is worthwhile to improve the I/O efficiency with purely random access to the disk It is worthwhile to improve the I/O efficiency with purely random access to the disk
53
DEVICE MANAGEMENT Disk Scheduling Policies Seek time is the reason for differences in performance. Seek time is the reason for differences in performance. For a single disk there will be a number of I/O requests. For a single disk there will be a number of I/O requests. If requests are selected randomly, we will get the worst possible performance. If requests are selected randomly, we will get the worst possible performance.
54
DEVICE MANAGEMENT Disk Scheduling Policies First-in, first-out (FIFO) First-in, first-out (FIFO) ٭Process request sequentially. ٭Fair to all processes. ٭Approaches random scheduling in performance if there are many processes.
55
DEVICE MANAGEMENT Disk Scheduling Policies Priority 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.
56
DEVICE MANAGEMENT FIFO (Starting at Track 100) 55 58 39 18 90 160 150 38 184
57
DEVICE MANAGEMENT Disk Scheduling Policies Last-in, first-out Last-in, first-out ٭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
58
DEVICE MANAGEMENT Disk Scheduling Policies Shortest Service Time First 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
59
DEVICE MANAGEMENT 55 58 39 18 90 160 150 38 184 SSTF
60
DEVICE MANAGEMENT Disk Scheduling Policies SCAN SCAN ٭Arm moves in one direction only, satisfying all outstanding requests until it reaches the last track in that direction ٭Direction is reversed ٭Max delay:2T. T: a scan time from inner track to outer track
61
DEVICE MANAGEMENT SCAN 55 58 39 18 90 160 150 38 184
62
DEVICE MANAGEMENT Disk Scheduling Policies C-SCAN C-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 ٭Max delay: T+Smax. Smax is the maximum seek time
63
DEVICE MANAGEMENT CSCAN 55 58 39 18 90 160 150 38 184
64
DEVICE MANAGEMENT Disk Scheduling Policies N-step-SCAN 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 FSCAN ٭Two queues ٭One queue is empty for new request
65
DEVICE MANAGEMENT
66
Figure 11.7 P469
67
DEVICE MANAGEMENT RAID(p471) Redundant Array of Inexpensive Disks Redundant Array of Inexpensive Disks Redundant Array of Independent Disks Redundant Array of Independent Disks
68
DEVICE MANAGEMENT RAID Using multiple disks can: Using multiple disks can: ٭I/O requests can be handled in parallel. ٭The reliability of disk can be improved.
69
DEVICE MANAGEMENT RAID Characteristics RAID is a set of physical disk drives viewed by the operating system as a single logical drive. (transparent) RAID is a set of physical disk drives viewed by the operating system as a single logical drive. (transparent) Data are distributed across the physical drives of an array.(distributed) Data are distributed across the physical drives of an array.(distributed) Redundant disk capacity is used to store parity information, which guarantees data recoverability in case of disk failure.(reliability) Redundant disk capacity is used to store parity information, which guarantees data recoverability in case of disk failure.(reliability)
70
DEVICE MANAGEMENT Strip Unit( ) Data are striped across the available disks. (fig 11.9)The strips are mapped round robin to consecutive array members. Data are striped across the available disks. (fig 11.9)The strips are mapped round robin to consecutive array members. Small strip: Small strip: ٭Parallel Access Technique Large strip: Large strip: ٭Independent Access Technique
71
DEVICE MANAGEMENT Verify Methods Mirror storage Mirror storage Hamming code(distance =n) Hamming code(distance =n) Parity verify (distance =2) Parity verify (distance =2) ٭X4(i) X3(i)+X2(i)+X1(i)+X0(i) ٭X1(i) X4(i)+X3(i)+X2(i)+X0(i) ٭Distribute or centralize storage
72
DEVICE MANAGEMENT RAID Characteristics Strip unit and storage method Strip unit and storage method Verify method and storage method Verify method and storage method
73
DEVICE MANAGEMENT RAID 0 (non-redundant)
74
DEVICE MANAGEMENT RAID 0
75
DEVICE MANAGEMENT RAID 0 non-redundant non-redundant non-verify non-verify distributed storage distributed storage Lower reliability Lower reliability Lower cost Lower cost Parallel I/O access Parallel I/O access
76
DEVICE MANAGEMENT RAID 1 (Mirrored) Distributed Distributed Mirrored/redundancy Mirrored/redundancy No verify No verify
77
DEVICE MANAGEMENT RAID 1 Read performance is better than RAID 0 (choose the seek time fewer disk to access) Read performance is better than RAID 0 (choose the seek time fewer disk to access) Write performance is worse than RAID 0 Write performance is worse than RAID 0 Higher cost Higher cost Recovery is simple Recovery is simple It can have higher parallel performance than RAID0 It can have higher parallel performance than RAID0
78
DEVICE MANAGEMENT RAID 2 (Redundancy Through Hamming Code)
79
DEVICE MANAGEMENT RAID 2 Strips are very small, as a single byte or word. Strips are very small, as a single byte or word. Hamming code in special disks Hamming code in special disks Lower cost than RAID1 but higher than RAID3, 4,5 Lower cost than RAID1 but higher than RAID3, 4,5
80
DEVICE MANAGEMENT RAID 3 (Bit-Interleaved Parity) Same as RAID2 but use parity verify,so it only need a single redundant disk Same as RAID2 but use parity verify,so it only need a single redundant disk
81
DEVICE MANAGEMENT RAID 3Performance Small strip bringParallel Access Technique but only one I/O request can be executed at a time. Small strip bring Parallel Access Technique but only one I/O request can be executed at a time. Lower cost than RAID2. Lower cost than RAID2.
82
DEVICE MANAGEMENT RAID 4 (Block-Level Parity)
83
DEVICE MANAGEMENT RAID 4 Large strip Large strip Parity verify and storage into a special disk Parity verify and storage into a special disk Parity disk become a bottleneck Parity disk become a bottleneck
84
DEVICE MANAGEMENT RAID 5 (Block-Level Distributed Parity)
85
DEVICE MANAGEMENT RAID 5 Same as RAID4 but parity information distributed Same as RAID4 but parity information distributed Avoid bottleneck found in RAID Level 4 Avoid bottleneck found in RAID Level 4
86
DEVICE MANAGEMENT Disk Cache(p479) Buffer in main memory for disk sectors. Buffer in main memory for disk sectors. Contains a copy of some of the sectors on the disk. Contains a copy of some of the sectors on the disk. According to locality principle to cache. According to locality principle to cache.
87
DEVICE MANAGEMENT Using Methods From disk-cache copy to user process space. From disk-cache copy to user process space. Using a shared memory capability and passing a pointer to the appropriate slot in the disk cache. Using a shared memory capability and passing a pointer to the appropriate slot in the disk cache.
88
DEVICE MANAGEMENT Least Recently Used (I) The block that has been in the cache the longest with no reference to it is replaced. 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. The cache consists of a stack of blocks. Most recently referenced block is on the top of the stack. 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. When a block is referenced or brought into the cache, it is placed on the top of the stack.
89
DEVICE MANAGEMENT Least Recently Used (I) The block on the bottom of the stack is removed when a new block is brought in. 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. Blocks dont actually move around in main memory. A stack of pointers is used. A stack of pointers is used.
90
DEVICE MANAGEMENT Least Frequently Used (II) The block that has experienced the fewest references is replaced. The block that has experienced the fewest references is replaced. A counter is associated with each block. A counter is associated with each block. Counter is incremented each time block accessed. Counter is incremented each time block accessed. Block with smallest count is selected for replacement. 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. Some blocks may be referenced many times in a short period of time and then not needed any more.
91
DEVICE MANAGEMENT Integrate Methods(1)
92
DEVICE MANAGEMENT Integrate Methods(1) A area in new section, the count not add. A area in new section, the count not add. A area whose count is the least in old section will be replaced. A area whose count is the least in old section will be replaced. The count remains at 1 as long as the block remains in the new section The count remains at 1 as long as the block remains in the new section
93
DEVICE MANAGEMENT Integrate Methods(2)
94
DEVICE MANAGEMENT Integrate Methods(2) The count in middle section can add, but not replace the area in this section The count in middle section can add, but not replace the area in this section
95
DEVICE MANAGEMENT Appendix 11a p492 Disk storage devices Disk storage devices
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.