Before We Begin CSE 120 Principles of Operating Systems Read Chapter 11 on I O Systems Lecture 11 I O System Software November 18 2003 Prof Joe Pasquale Department of Computer Science and Engineering University of California San Diego 2003 by Joseph Pasquale 2 1 What is I O Background on I O Hardware Input output between CPU memory and I O devices I O bus interconnects CPU memory I O devs Problems A device generally connects to the bus via a controller So many different types of I O devices Controller has registers that CPU can read write via Wide range in speed operation data transfer units I O instructions memory instructions memory mapped Questions Data transfer programmed I O vs DMA How does a process initiate I O Synchronization polling vs interrupts How is synchronization achieved How is data transferred 3 4 Classifying Devices I O Layered Software Structure User I O stdio library classify by shared characteristics imposes structure shared code lower complexity Dimensions character stream vs block Kernel User So many different types of devices sequential vs random access Hardware synchronous vs asynchronous sharable vs dedicated speed of operation Device Independent I O buffering caching block vs char Device driver Device driver Device driver Device Device Device controller controller controller Device Dev Dev Device 5 Device Drivers Device controller Dev Dev 6 Device Independent I O Software Encapsulates device dependent code Uniform interfacing for device drivers Generally must implement a standard interface Naming protection Code contains device specific register reads writes Buffering caching Interrupt handlers Device independent block size Handler executes when I O operation completes Storage allocation for block devices May be converted to a software interrupt Locking dedicated devices Updates data structures Wakes up process that was waiting Error handling 7 8 User Space I O Software Overall Operation Richer or simplified interface User Process I O request e g putchar getchar vs read write User level buffering I O response Device Independent I O e g stdio library Spooling daemons Printer Make I O call format I O spooling Naming protection blocking buffering allocation Device Driver Upper synch Control via device registers check status Interrupt Handlers asynch Wakeup driver when I O completed Hardware Perform I O operation 9 10 Example Unix I O Unix I O System Calls Via file system interface File Subsystem open close read Buffer Cache Character write Ioctl Block Device Drivers 11 12 Unix Buffered vs Unbuffered I O Buffered I O Unix Standard I O Library fopen fread fwrite fprintf fscanf fclose system buffers buffer cache character queues Private buffer kept in user space Unbuffered I O Minimizes the number of I O system calls data transferred directly between proc and dev can be via DMA 13 Unix Block vs Character Devices 14 Unix The Buffer Cache Block Cache of recently used blocks transfer units in fixed size blocks Each block has an address device block blocks are addressable random access Three lists kept in buffer cache device list hash table linked lists Character transfer units in variable size sequence of bytes used for all non block devices free list driver I O queue LRU is used for replacement linked list of character queues 15 16
View Full Document
Unlocking...