Advanced Operating Systems - Lecture 35: Principles of I/O software. This lecture will cover the following: 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);...
Trang 1CS703 Advanced Operating Systems
By Mr Farhan Zaidi
Trang 235
Trang 3 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)
Trang 4 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
Trang 5 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
Trang 6Layers of the I/O system and the main functions of each layer
Trang 7 Memory mapped 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.
Trang 8Writing a string to the printer using programmed I/O
Trang 9 Writing a string to the printer using interrupt-driven I/O
a Code executed when print system call is made
b Interrupt service procedure
Trang 10main memory
I/O bridge bus interface
ALU register file
CPU chip
system bus memory bus
disk controller
graphics adapter
USB controller
mouse keyboard monitor
disk
I/O bus Expansion slots for
other devices such
as network adapters.
Trang 11
main memory
ALU register file
CPU chip
disk controller
graphics adapter
USB controller
mouse keyboard monitor
disk
I/O bus bus interface
CPU initiates a disk read by writing a command, logical block number, and destination memory address to a port (address) associated with disk controller.
Trang 12main memory
ALU register file
CPU chip
disk controller
graphics adapter
USB controller
mouse keyboard monitor
disk
I/O bus bus interface
Disk controller reads the sector and performs a direct memory access (DMA) transfer into main memory.
Trang 13main memory
ALU register file
CPU chip
disk controller
graphics adapter
USB controller
mouse keyboard monitor
disk
I/O bus bus interface
When the DMA transfer completes, the disk controller notifies the CPU with an
interrupt (i.e., asserts a special “interrupt”
pin on the CPU)
Trang 14Operation of a DMA transfer
Trang 15 Printing a string using DMA
a code executed when the print system call is made
b interrupt service procedure