1 / 38

Device Management

Device Management. 5. Input/Output Devices. Output Device. Processor. Input Device. The Device Driver Interface. … write(…); …. Device Interface. Terminal Driver. Printer Driver. Disk Driver. Terminal Controller. Printer Controller. Disk Controller.

lanza
Télécharger la présentation

Device Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating Systems: A Modern Perspective, Chapter 5

  2. DeviceManagement 5 Operating Systems: A Modern Perspective, Chapter 5

  3. Input/Output Devices Output Device Processor Input Device Operating Systems: A Modern Perspective, Chapter 5

  4. The Device Driver Interface … write(…); … Device Interface Terminal Driver Printer Driver Disk Driver Terminal Controller Printer Controller Disk Controller Operating Systems: A Modern Perspective, Chapter 5

  5. Device Management Organization Application Process System Interface File Manager Device-Independent Device-Dependent Hardware Interface Command Status Data Device Controller Operating Systems: A Modern Perspective, Chapter 5

  6. System Call Interface • Functions available to application programs • Abstract all devices (and files) to a few interfaces • Make interfaces as similar as possible • Block vs character • Sequential vs direct access • Device driver implements functions (one entry point per API function) Operating Systems: A Modern Perspective, Chapter 5

  7. Example: BSD UNIX Driver open Prepare dev for operation close No longer using the device ioctl Character dev specific info read Character dev input op write Character dev output op strategy Block dev input/output ops select Character dev check for data stop Discontinue a stream output op Operating Systems: A Modern Perspective, Chapter 5

  8. Overlapping the Operation of a Device and the CPU . . . startRead(dev_I, “%d”, x); . . . While(stillReading()) ; y = f(x) . . . . . . read(dev_I, “%d”, x); y = f(x) . . . Data on device Variable x Register Device dev_I Memory CPU Operating Systems: A Modern Perspective, Chapter 5

  9. Overlapping CPU-Controller Operations in a Process App I/O Ctlr t1 t2 t3 t4 t5 t6 t7 t8 t9 Operating Systems: A Modern Perspective, Chapter 5

  10. Overlapping Processing and I/O App 1 App 2 I/O Ctlr t1 t2 t3 t4 Operating Systems: A Modern Perspective, Chapter 5

  11. Polling I/O Read Operation read(device, …); 1 Data System Interface read function 5 write function 2 3 4 Hardware Interface Command Status Data Device Controller Operating Systems: A Modern Perspective, Chapter 5

  12. Interrupt-driven I/O Operation read(device, …); 9 1 8b Data System Interface Device Status Table 4 7 Device Handler read driver 2 write driver 6 3 8a Interrupt Handler Hardware Interface 5 Command Status Data Device Controller Operating Systems: A Modern Perspective, Chapter 5

  13. Device Independent Function Call Trap Table funci(…) dev_func_i(devID, …) { // Processing common to all devices … switch(devID) { case dev0: dev0_func_i(…); break; case dev1: dev1_func_i(…); break; … case devM: devM_func_i(…); break; }; // Processing common to all devices … } Operating Systems: A Modern Perspective, Chapter 5

  14. Driver-Kernel Interface • Drivers are distinct from main part of kernel • Kernel makes calls on specific functions, drivers implement them • Drivers use kernel functions for: • Device allocation • Resource (e.g., memory) allocation • Scheduling • etc. (varies from OS to OS) Operating Systems: A Modern Perspective, Chapter 5

  15. Reconfigurable Device Drivers System call interface open(){…} read(){…} Entry Points for Device j etc. Other Kernel services Driver for Device j Operating Systems: A Modern Perspective, Chapter 5

  16. Handling Interrupts Device driver J Device interrupt handler J Device status table int read(…) { // Prepare for I/O save_state(J); out dev# // Done (no return) } void dev_handler(…) { get_state(J); //Cleanup after op signal(dev[j]); return_from_sys_call(); } J Interrupt Handler Device Controller Operating Systems: A Modern Perspective, Chapter 5

  17. Handling Interrupts(2) Device driver J Device interrupt handler J int read(…) { … out dev# // Return after interrupt wait(dev[J}); return_from_sys_call(); } void dev_handler(…) { //Cleanup after op signal(dev[j]); } Interrupt Handler Device Controller Operating Systems: A Modern Perspective, Chapter 5

  18. The Pure Cycle Water Company Customer Office Water Company Returning the Empties Water Producer Water Consumers Delivering Water Operating Systems: A Modern Perspective, Chapter 5

  19. Hardware Buffering Process Process Process Controller Controller Controller Data A B A B Device Device Device Process reads bi-1 Controller reads bi Process reads bi Controller reads bi+1 Unbuffered Operating Systems: A Modern Perspective, Chapter 5

  20. Double Buffering in the Driver Process Process A B A B Driver Controller Controller A B A B Hardware Device Device Operating Systems: A Modern Perspective, Chapter 5

  21. Circular Buffering To data consumer Buffer i Buffer j From data producer Operating Systems: A Modern Perspective, Chapter 5

  22. A Generic Communications Device Bus Generic Controller Communications Controller Local Device Cabling connecting the controller to the device Device • Printer • Modem • Network Operating Systems: A Modern Perspective, Chapter 5

  23. Rotating Media Cylinder (set of tracks) Track (Cylinder) Sector (a) Multi-surface Disk (b) Disk Surface (b) Cylinders Operating Systems: A Modern Perspective, Chapter 5

  24. Storage Device Device Driver API • Driver • Get disk description • Set SCSI parms • read/write ops • Interrupt hander • SCSI API • commands • bits per byte • etc. Controller (SCSI) Magnetic Disk Operating Systems: A Modern Perspective, Chapter 5

  25. Compute vs I/O Bound Compute-bound Time I/O-bound Operating Systems: A Modern Perspective, Chapter 5

  26. Disk Optimizations • Transfer Time: Time to copy bits from disk surface to memory • Disk latency time: Rotational delay waiting for proper sector to rotate under R/W head • Disk seek time: Delay while R/W head moves to the destination track/cylinder • Access Time = seek + latency + transfer Operating Systems: A Modern Perspective, Chapter 5

  27. Optimizing Seek Time • Multiprogramming on I/O-bound programs => set of processes waiting for disk • Seek time dominates access time => minimize seek time across the set • Tracks 0:99; Head at track 75, requests for 23, 87, 36, 93, 66 • FCFS: 52+ 64 + 51 + 57 + 27 = 251 steps Operating Systems: A Modern Perspective, Chapter 5

  28. Optimizing Seek Time (cont) • Requests = 23, 87, 36, 93, 66 • SSTF: (75), 66, 87, 93, 36, 23 • 11 + 21 + 6 + 57 + 13 = 107 steps • Scan: (75), 87, 93, 99, 66, 36, 23 • 12 + 6 + 6 + 33 + 30 + 13 = 100 steps • Look: (75), 87, 93, 66, 36, 23 • 12 + 6 + 27 + 30 + 13 = 87 steps Operating Systems: A Modern Perspective, Chapter 5

  29. Optimizing Seek Time (cont) • Requests = 23, 87, 36, 93, 66 • Circular Scan: (75), 87, 93, 99, 23, 36, 66 • 12 + 6 + 6 + home + 23 + 13 + 30 = 90 + home • Circular Look: (75), 87, 93, 23, 36, 66 • 12 + 6 + home + 23 + 13 + 30 = 84 + home Operating Systems: A Modern Perspective, Chapter 5

  30. Serial Port CPU Memory Serial Device • Printer • Terminal • Modem • Mouse • etc. Operating Systems: A Modern Perspective, Chapter 5

  31. Serial Port Device Driver API • Device Driver • Set UART parms • read/write ops • Interrupt hander Software on the CPU Bus Interface • UART API • parity • bits per byte • etc. Serial Device (UART) • RS-232 Interface • 9-pin connector • 4-wires • bit transmit/receive • ... Operating Systems: A Modern Perspective, Chapter 5

  32. Adding a Modem CPU • Dialing & connecting • Convert analog voice to/from digital • Convert bytes to/from bit streams • Transmit/receive protocol Memory Serial Device Modem Phone Switched Telephone Network Operating Systems: A Modern Perspective, Chapter 5

  33. Serial Communication • Device Driver • Set UART parms • read/write ops • Interrupt hander • Driver-Modem Protocol • Dialing & connecting • Convert analog voice to/from digital • Convert bytes to/from bit streams • Transmit/receive protocol Serial Device RS-232 Modem Operating Systems: A Modern Perspective, Chapter 5

  34. Exploiting the Phone Network Logical Communication CPU CPU Memory Comm Device Comm Device Memory Modem Modem Phone Phone Switched Telephone Network Operating Systems: A Modern Perspective, Chapter 5

  35. Data Networks • Technology focus includes protocols and software • (more on this later … Chapter 15 and beyond ...) Logical Communication CPU CPU Memory Network Device Network Device Memory Data Network Operating Systems: A Modern Perspective, Chapter 5

  36. MS Disk Description Operating Systems: A Modern Perspective, Chapter 5

  37. NT Driver Organization Operating Systems: A Modern Perspective, Chapter 5

  38. NT Device Drivers • API model is the same as for a file • Extend device management by adding modules to the stream • Device driver is invoked via an Interrupt Request Packet (IRP) • IRP can come from another stream module • IRP can come from the OS • Driver must respond to minimum set of IRPs • See Part I of notes Operating Systems: A Modern Perspective, Chapter 5

More Related