2 Chapter ObjectivesWhen finish this chapter, you will understand the following:How operating systems manage I/O?What is role of Device Driver?How mass storage disk works?
3 IntroductionThe devices that attach to a computer vary in many aspects.Some transfer data synchronously, others asynchronously. Some are dedicated, some shared. They can be read-only or read-write.The control of devices connected to the computer is a major concern of operating system designers.
4 I/O Hardware Incredible variety of I/O devices Common concepts PortBus (daisy chain or shared direct access)Controller (host adapter)I/O instructions control devicesDevices have addresses, used byDirect I/O instructionsMemory-mapped I/O
7 Polling Determines state of device command-readybusyErrorBusy-wait cycle to wait for I/O from device
8 Interrupts CPU Interrupt request line triggered by I/O device Interrupt handler receives interruptsMaskable to ignore or delay some interruptsInterrupt vector to dispatch interrupt to correct handlerBased on prioritySome unmaskableInterrupt mechanism also used for exceptions
12 Application I/O Interface (Device Driver) I/O system calls encapsulate device behaviors in generic classesDevice-driver layer hides differences among I/O controllers from kernelDevices vary in many dimensionsCharacter-stream or blockSequential or random-accessSharable or dedicatedSpeed of operationread-write, read only, or write only
14 Improving Performance Reduce number of context switchesReduce data copyingReduce interrupts by using large transfers, smart controllers, pollingUse DMABalance CPU, memory, bus, and I/O performance for highest throughput
15 Mass-Storage Systems-Disk Structure Disk drives are addressed as large 1-dimensional arrays of logical blocks, where the logical block is the smallest unit of transfer.The 1-dimensional array of logical blocks is mapped into the sectors of the disk sequentially.Sector 0 is the first sector of the first track on the outermost cylinder.Mapping proceeds in order through that track, then the rest of the tracks in that cylinder, and then through the rest of the cylinders from outermost to innermost.
16 Disk SchedulingThe operating system is responsible for using hardware efficiently — for the disk drives, this means having a fast access time and disk bandwidth.Access time has two major componentsSeek time is the time for the disk are to move the heads to the cylinder containing the desired sector.Rotational latency is the additional time waiting for the disk to rotate the desired sector to the disk head.Minimize seek timeSeek time seek distanceDisk bandwidth is the total number of bytes transferred
17 Disk Scheduling (Cont.) Several algorithms exist to schedule the servicing of disk I/O requests.We illustrate them with a request queue (0-199).98, 183, 37, 122, 14, 124, 65, 67Head pointer 53
18 FCFS -Illustration shows total head movement of 640 cylinders.
20 Disk ManagementLow-level formatting, or physical formatting — Dividing a disk into sectors that the disk controller can read and write.To use a disk to hold files, the operating system still needs to record its own data structures on the disk.Partition the disk into one or more groups of cylinders.Logical formatting or “making a file system”.Boot block initializes system.The bootstrap is stored in ROM.Bootstrap loader program.Methods such as sector sparing used to handle bad blocks.