INPUT OUTPUT MANAGEMENT Prepared By: Dr. Vipul Vekariya
2 I/O M ANAGEMENT One of the main function of the OS is to control the all the computer’s I/O devices. It should provide the an interface between the devices and rest of the system that is simple and easy to use. To the extent possible, the interface should be same for all devices.( device independence)
I/O D EVICES. I/O Devices can be divided in two categories. Block devices : it is store the information in fixed size blocks, each one with its own address. Common block sizes range from 512 bytes to bytes. Disk are the most common block devices. Character devices : it deliver or accept a stream of characters. Printer, network card are character devices.
4 D EVICE C ONTROLLERS I/O devices have components: mechanical component electronic component The electronic component is the device controller may be able to handle multiple devices Controller's tasks convert serial bit stream to block of bytes perform error correction as necessary make available to main memory
M EMORY -M APPED I/O Each controller has a few register that are used for communicating with CPU. By writing in to register, the OS can command the device to deliver data, accept data, switch itself on or off. By reading this register, the OS can learn what the devices' state is. In addition to the control register, many devices have a data buffer the OS can read or write. The issues arises of how the CPU communicate with the control registers and the device data buffer. 5
I/O T ECHNIQUES When the processor encounters an instruction relating to I/O, it executes that instruction by issuing a command to the appropriate I/O module. Three techniques are possible for I/O operations: Programmed I/O Interrupt-driven I/O Direct memory access (DMA) 6
P ROGRAMMED I/O E XAMPLE Data read in a word at a time Processor remains in status-checking look while reading
I NTERRUPT -D RIVEN I/O Processor issues an I/O command to a module and then goes on to do some other useful work. The I/O module will then interrupt the processor to request service when it is ready to exchange data with the processor.
I NTERRUPT - D RIVEN I/O Eliminates needless waiting But everything passes through processor.
D IRECT M EMORY A CCESS Performed by a separate module on the system When needing to read/write processor issues a command to DMA module with: Whether a read or write is requested The address of the I/O device involved The starting location in memory to read/write The number of words to be read/written
11 D IRECT M EMORY A CCESS (DMA) Operation of a DMA transfer
D IRECT M EMORY A CCESS I/O operation delegated to DMA module Processor only involved when beginning and ending transfer. Much more efficient.
13 P RINCIPLES OF I/O S OFTWARE G OALS OF I/O S OFTWARE Device independence programs can access any I/O device without specifying device in advance · (floppy, hard drive, or CD-ROM) Uniform naming name of a file or device a string or an integer not depending on which machine Error handling handle as close to the hardware as possible
14 I/O S OFTWARE L AYERS Layers of the I/O Software System
D EVICE DRIVERS A device driver simplifies programming by acting as a translator between a hardware device and the applications or operating systems.operating systems When a calling program invokes a routine in the driver, the driver issues commands to the device. Once the device sends data back to the driver, the driver may invoke routines in the original calling program.routine Device driver check the input parameter to see if they are valid. If not error is returned. Driver may check if the device is currently in use or not. It may be necessary to switch the device on or motor before transfer can begin. It may also need to mange its power requirement and log events. 15
16 D EVICE D RIVERS Logical position of device drivers is shown here Communications between drivers and device controllers goes over the bus
RAID Patterson et al. suggested six specific disk organization that could be used to improve disk performance. This idea were quickly adopted by industry and have to a new class of I/O devices called a RAID. Redundant array of independent disks. The basic idea behind RAID is to install a box full of disks next to the computer. Typically a large server, replace the disk controller card with the RAID controller. SCSI is Small Computer System Interface. It is a high speed bus interface that links the CD-ROM drive, Hard disk drive, and numerous other peripherals. 17
RAID RAID is a set of physical disk drives viewed by the operating system as a single logical drives. Data are distributed across the physical drives of an array in a scheme known as stripping. Redundant disk capacity is used to store parity information, which guarantees data recoverability in case of a disk failure. 18
RAID 0 A RAID 0 (also known as a stripe set or striped volume ) splits data evenly across two or more disks (striped)striped It is important to note that RAID 0 was not one of the original RAID levels and provides no data redundancy.data redundancy RAID 0 is normally used to increase performance, 19
RAID 1 A RAID 1 creates an exact copy (or mirror ) of a set of data on two or more disks. This is useful when read performance or reliability are more important than data storage capacity.capacity Such an array can only be as big as the smallest member disk. A classic RAID 1 mirrored pair contains two disks (see diagram), which increases reliability geometrically over a single disk. geometrically Since each member contains a complete copy of the data, and can be addressed independently, ordinary wear-and-tear reliability is raised by the power of the number of self-contained copies. 20
RAID 2 A RAID 2 stripes data at the bit (rather than block) level, and uses a Hamming code for error correction.bitHamming codeerror correction RAID level 2 and 3 make use of parallel access technique. In parallel access, all member disks participate in the execution of every I/O request. Spindle of individual drives are synchronize so each disk head in the same position on each disk at any given time. Extremely high data transfer rates are possible. This is the only original level of RAID that is not currently used. 21
RAID 3 It is simplified version of RAID 2. A RAID 3 uses byte-level striping with a dedicated parity diskbyte Here single parity bit is computed for each data word and written to parity drive. 22
RAID LEVEL 4 A RAID 4 uses block-level striping with a dedicated parity disk.block Independent access technique, each member disk operate independently This allows each member of the set to act independently when only a single block is requested. If the disk controller allows it, a RAID 4 set can service multiple read requests simultaneously. 23
RAID LEVEL 5 A RAID 5 uses block-level striping with parity data distributed across all member disks.block RAID 5 has achieved popularity because of its low cost of redundancy. 24
D ISK P ERFORMANCE P ARAMETERS Access Time is the sum of: Seek time: The time it takes to position the head at the desired track Rotational delay or rotational latency: The time its takes for the beginning of the sector to reach the head Transfer Time is the time taken to transfer the data.
D ISK S CHEDULING A LGORITHM To compare various schemes, consider a disk head is initially located at track 100. assume a disk with 200 tracks and that the disk request queue has random requests in it. The requested tracks, in the order received by the disk scheduler, are 55, 58, 39, 18, 90, 160, 150, 38, 184.
F IRST - IN, FIRST - OUT (FIFO) Process request sequentially Fair to all processes Approaches random scheduling in performance if there are many processes
S HORTEST S ERVICE T IME F IRST (SSTF) 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
SCAN ( E LEVATOR ALGORITHM ) Arm moves in one direction only, satisfying all outstanding requests until it reaches the last track in that direction then the direction is reversed
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
P ERFORMANCE C OMPARED Comparison of Disk Scheduling Algorithms