Unformatted text preview:

Review Want Standard Interfaces to Devices Block Devices e g disk drives tape drives Cdrom CS162 Operating Systems and Systems Programming Lecture 17 Access blocks of data Commands include open read write seek Raw I O or file system access Memory mapped file access possible Character Devices e g keyboards mice serial ports some USB devices Disk Management and File Systems Single characters at a time Commands include get put Libraries layered on top allow line editing Network Devices e g Ethernet Wireless Bluetooth October 29 2008 Prof John Kubiatowicz http inst eecs berkeley edu cs162 Different enough from block character to have own interface Unix and Windows include socket interface Separates network protocol from network operation Includes select functionality Usage pipes FIFOs streams queues mailboxes 10 29 08 Kubiatowicz CS162 UCB Fall 2008 Review How Does User Deal with Timing Goals for Today Blocking Interface Wait When request data e g read system call put process to sleep until data is ready When write data e g write system call put process to sleep until device is ready for data Finish Discussing I O Systems Hardware Access Device Drivers Disk Performance Hardware performance parameters Queuing Theory Non blocking Interface Don t Wait Returns quickly from read or write request with count of bytes successfully transferred Read may return nothing write may write nothing File Systems Structure Naming Directories and Caching Asynchronous Interface Tell Me Later When request data take pointer to user s buffer return immediately later kernel fills buffer and notifies user When send data take pointer to user s buffer return immediately later kernel takes data and notifies user 10 29 08 Kubiatowicz CS162 UCB Fall 2008 Lec 17 2 Lec 17 3 Note Some slides and or pictures in the following are adapted from slides 2005 Silberschatz Galvin and Gagne Gagne Many slides generated from my lecture notes by Kubiatowicz 10 29 08 Kubiatowicz CS162 UCB Fall 2008 Lec 17 4 Main components of Intel Chipset Pentium 4 How does the processor talk to the device Processor Memory Bus CPU Northbridge Handles memory Graphics Interrupt Controller Southbridge I O PCI bus Disk controllers USB controllers Audio Serial I O Interrupt controller Timers 10 29 08 Addr 0x8000F000 0x8000FFFF Say enter a set of triangles that describe some scene Addr 0x80010000 0x8001FFFF Addressable Memory and or Queues Memory Mapped Region 0x8f008020 Example from the Intel architecture out 0x21 AL Memory mapped I O load store instructions Lec 17 5 0x80020000 Graphics Command Queue Display Memory 0x8000F000 0x0007F004 0x0007F000 Say render the above scene Addr 0x0007F004 10 29 08 read write control status Registers port 0x20 I O instructions in out instructions Writing to the command register may cause on board graphics hardware to do something Can protect with page tables Hardware Controller Bus Interface Regardless of the complexity of the connections and buses processor accesses registers in two ways Addresses set by hardware jumpers or programming at boot time 0x80010000 Writing graphics description to command queue area Interrupt Request Device Controller can be read and written May contain memory for request queues or bit mapped images Memory Mapped Display Controller Example Memory Mapped Simply writing to display memory also called the frame buffer changes image on screen Other Devices or Buses Bus Adaptor Address Data CPU interacts with a Controller Contains a set of registers that Kubiatowicz CS162 UCB Fall 2008 Hardware maps control registers and display memory to physical address space Bus Adaptor Regular Memory Kubiatowicz CS162 UCB Fall 2008 10 29 08 Registers memory appear in physical address space I O accomplished with load and store instructions Kubiatowicz CS162 UCB Fall 2008 Lec 17 6 Transferring Data To From Controller Programmed I O Each byte transferred via processor in out or load store Pro Simple hardware easy to program Con Consumes processor cycles proportional to data size Direct Memory Access Give controller access to memory bus Ask it to transfer data to from memory directly Sample interaction with DMA controller from book Command Status Physical Address Space Lec 17 7 10 29 08 Kubiatowicz CS162 UCB Fall 2008 Lec 17 8 A Kernel I O Structure Administrivia Group Evaluations Both Projects 1 and 2 These MUST be done you will get a ZERO on your project score if you don t fill them out We will be asking you about them so make sure you are careful to fill them out honestly Next Week s Sections Fill out a survey form to see how class is going Give you an opportunity to give feedback Other things Group problems Don t wait Talk to TA talk to me Let s get things fixed 10 29 08 Kubiatowicz CS162 UCB Fall 2008 Lec 17 9 10 29 08 Device Drivers Device Driver Device specific code in the kernel that interacts directly with the device hardware User Program Kernel I O Subsystem Device Drivers typically divided into two pieces Top half accessed in call path from system calls Device Driver Top Half implements a set of standard cross device calls like open close read write ioctl strategy This is the kernel s interface to the device driver Top half will start I O to device may put thread to sleep until finished Device Driver Bottom Half Bottom half run as interrupt routine Device Hardware Gets input or transfers next block of output May wake sleeping threads if I O now complete Kubiatowicz CS162 UCB Fall 2008 Lec 17 10 Life Cycle of An I O Request Supports a standard internal interface Same kernel I O system can interact easily with different device drivers Special device specific configuration supported with the ioctl system call 10 29 08 Kubiatowicz CS162 UCB Fall 2008 Lec 17 11 10 29 08 Kubiatowicz CS162 UCB Fall 2008 Lec 17 12 Hard Disk Drives I O Device Notifying the OS The OS needs to know when The I O device has completed an operation The I O operation has encountered an error I O Interrupt Device generates an interrupt whenever it needs service Handled in bottom half of device driver Often run on special kernel level stack Pro handles unpredictable events well Con interrupts relatively high overhead Read Write Head Side View Polling OS periodically checks a device specific status register I O device puts completion information in status register Could use timer to invoke lower half of drivers occasionally Pro low overhead Con may waste many cycles on polling if infrequent or unpredictable I O operations Actual


View Full Document

Berkeley COMPSCI 162 - Lecture 17

Documents in this Course
Lecture 1

Lecture 1

12 pages

Nachos

Nachos

41 pages

Security

Security

39 pages

Load more
Loading Unlocking...
Login

Join to view Lecture 17 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 17 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?