CS703 - Advanced Operating Systems By Mr. Farhan Zaidi
Lecture No. 35
Overview of today’s lecture Goals of I/O software Layers of I/O software Direct Vs memory mapped I/O Interrupt driven I/O Polled I/O Direct Memory Access (DMA)
Principles of I/O Software Goals of I/O Software 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 Synchronous vs. asynchronous transfers blocked transfers vs. interrupt-driven Buffering data coming off a device cannot be stored in final destination immediately
Device Controllers mechanical component electronic component 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
Layers of the I/O system and the main functions of each layer
Memory mapped I/O Vs Direct I/O Device controller’s registers and internal memory are directly mapped into the processor’s address space Direct I/O Device controller’s registers and internal memory is accessible via special instructions in the assembly language instruction set. The arguments to these instructions are usually called ports.
Writing a string to the printer using programmed I/O
Interrupt-Driven I/O a. Code executed when print system call is made Writing a string to the printer using interrupt-driven I/O a. Code executed when print system call is made b. Interrupt service procedure
A Typical Hardware System CPU chip register file ALU system bus memory bus main memory bus interface I/O bridge I/O bus Expansion slots for other devices such as network adapters. USB controller graphics adapter disk controller mouse keyboard monitor disk
Reading a Disk Sector: Step 1 CPU chip CPU initiates a disk read by writing a command, logical block number, and destination memory address to a port (address) associated with disk controller. register file ALU main memory bus interface I/O bus USB controller graphics adapter disk controller mouse keyboard monitor disk
Reading a Disk Sector: Step 2 CPU chip Disk controller reads the sector and performs a direct memory access (DMA) transfer into main memory. register file ALU main memory bus interface I/O bus USB controller graphics adapter disk controller mouse keyboard monitor disk
Reading a Disk Sector: Step 3 CPU chip When the DMA transfer completes, the disk controller notifies the CPU with an interrupt (i.e., asserts a special “interrupt” pin on the CPU) register file ALU main memory bus interface I/O bus USB controller graphics adapter disk controller mouse keyboard monitor disk
Direct Memory Access (DMA) Operation of a DMA transfer
I/O Using DMA a. code executed when the print system call is made Printing a string using DMA a. code executed when the print system call is made b. interrupt service procedure