950 likes | 963 Views
Explore I/O device overview, organization, buffering, disk scheduling techniques, and more. Learn about RAID systems and the evolution of I/O functions. Understand OS design issues for efficient I/O operations.
E N D
Chapter 4 Device Management and Disk Scheduling
Content • I/O device overview • I/O organization and architecture • I/O buffering • Disk scheduling • RAID • Notes: Difficult to develop a general, consistent solution. Just a generally discuss.
4.1 I/O Devices (P452) Three categories: • Human Readable Devices • Such as Keyboard, Mouse, Display, Printer and so on; • Machine Readable Devices • Such as Actuator, Controller, Sensor, Tape Drive, Disk Drive and so on; • Communication Devices • Such as Modem, Network Adapter and so on.
Classify • There are many sorting standard. E.g. data rates
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 than an ordinary user
Differences in I/O Devices • 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
4.2 Techniques for Performing I/O (p453 11.2) • Cyclic Test /Programmed • Interrupt-Driven • DMA Control
Programmed I/O --P29. • I/O module performs the action, not the processor • Sets appropriate bits in the I/O status register • No interrupts occur • Processor checks status until operation is complete • Busy-waits
Interrupt-Driven I/O • Processor is interrupted when I/O module ready to exchange data • Processor is free to do other work • No needless waiting • Consumes a lot of processor time because every word read or written passes through the processor
Direct Memory Access • Transfers a block of data directly to or from memory • An interrupt is sent when the task is complete • The processor is only involved at the beginning and end of the transfer
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
Evolution of the I/O Function • 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
Evolution of the I/O Function • 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 module has its own local memory • Its a computer in its own right
Direct Memory Access • 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 • The instruction cycle is suspended so data can be transferred • The CPU pauses one bus cycle • No interrupts occur while cycle stealing • Do not save context
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 number of words to be read or written, again communicated via the data lines and stored in the data count register.
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. • Cycle stealing causes the CPU to execute more slowly.
DMA • 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
4.3 Operating System Design Issues • 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
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
Struct general_op{ int (*read)(…) int (*write)(…) }; driver1: Struct general_op dev_op={ dev1_read, dev1_write }; driver2: Struct general_op dev_op={ dev2_read, dev2_write }; Gen_read(fd,…) { dev_op=map(fd); dev_op->read(…); }
Logical Structure of the I/O Function (e.g. Hierarchical p458) • 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 • Implement I/O instructions, channel commands, and controller orders. May use buffering techniques.
Logical Structure of the I/O Function • Scheduling and Control • This is the level of software that actually interacts with the I/O module and the device hardware.
4.4I/O Buffering(p460) • 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
I/O Buffering • Block-oriented • Information is stored in fixed sized blocks • Transfers are made a block at a time • Used for disks and tapes • 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
Single Buffer • Operating system assigns a buffer in the system portion of main memory for an I/O request • Block-oriented • Input transfers made to buffer • Block moved to user space when needed • Another block is moved into the buffer • Read ahead
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
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.
Single Buffer • 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
Double Buffer • 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. • Performance: max(C,T).
Circular Buffer • More than two buffers are used. • Each individual buffer is one unit in a circular buffer. • Used when I/O operation must keep up with process.
Disk and Disk Scheduling(p463) • The speed of processors and main memory has far outstripped that for disk access. • The performance of disk storage subsystem is of vital concern. • How to improve the performance of disk? • General methods • Special methods
Disk Structure • Headers • Cylinders • Tracks • Sectors • Capability=headers*cylinders*sectors*byte per sector
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 • movable-head system or fixed-head system • 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
Disk Performance Parameters • Data transfer time • Wait for device or channel
RPS (Rotational Positional Sensing) • When seek command has been issued, the channel is released to handle other I/O operations. • RPS miss. Must rotate again and reconnect again.
Seek Time Ts = m×n+s n=number of tracks traversed m=constant that depends on the disk drive s=startup time
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
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
Total Average Access Time Ta=Ts+Tr+T
A Timing Comparison • Seek time: 20ms • Transfer rate: 1MB/s • r=3600rpm • 512byte per sector • 32 sector per track • Suppose to read 128k data
A Timing Comparison • 60*16k=960k<1MB/s • Sequential organization (20+8.3+16.7)+(8.3+16.7)×7=220(ms) • Randomly organization (20+8.3+0.5)×256=7373(ms)