device management device management organization
play

Device Management Device Management Organization Application - PowerPoint PPT Presentation

Device Management Device Management Organization Application Application Process Process API File File Manager Manager Device Device Driver Driver Hardware Interface Command Status Data Command Status Data Device Controller


  1. Device Management

  2. Device Management Organization Application Application Process Process API File File Manager Manager Device Device Driver Driver Hardware Interface Command Status Data Command Status Data Device Controller

  3. Read with Polling read(device, …); 1 Data System Interface read function 5 write function 2 3 4 Hardware Interface Command Status Data Command Status Data Device Controller

  4. Read with Interrupts read(device, …); 9 1 8b Data System Interface Device Status Table 4 7 Device read driver Device Handler Handler 2 write driver 6 3 8a Interrupt Interrupt Handler Handler Hardware Interface 5 Command Status Data Command Status Data Device Controller

  5. CPU-I/O Overlap . . . . . . startRead(dev_I, “%d”, x); read(dev_I, “%d”, x); . . . y = f(x) While(stillReading()) ; . . . y = f(x) . . . Data on device Variable x Register Device dev_I Memory CPU

  6. I/O - CPU Overlap App 1 App 2 I/O Ctlr t 1 t 2 t 3 t 4 Overlapping App 1’s I/O with App 2 App I/O Ctlr t 1 t 2 t 3 t 4 t 5 t 6 t 7 t 8 t 9 Overlapping App CPU with its own I/O

  7. Memory Mapped I/O Memory Addresses Primary Primary Memory Memory Memory Addresses Device 0 Device 0 Device Addresses Device 1 Device 1 Device n-1 Device n-1

  8. Direct Memory Access Primary Primary Memory Memory CPU CPU Controller Controller Device Device

  9. Hardware Buffering Process Process Process Process Controller Controller Data A B Device Device Process reads b i-1 Unbuffered Controller reads b i

  10. Hardware Buffering Process Process Process Process Process Process Controller Controller Controller Data A B A B Device Device Device Process reads b i-1 Process reads b i Unbuffered Controller reads b i Controller reads b i+1

  11. Buffering in the Driver Process Process Driver A B Controller Hardware A B Device

  12. Buffering in the Driver Process Process Process Process Driver A B A B Controller Controller Hardware A B A B Device Device

  13. A Ring Buffer To data consumer Buffer i Buffer j From data producer

  14. Compute vs. I/O Bound Compute-bound Time I/O-bound

  15. Application Programming Interface • Functions available to application programs • Abstract all devices 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)

  16. BSD UNIX Driver Prepare dev for operation open No longer using the device close Character dev specific info ioctl Character dev input op read write Character dev output op Block dev input/output ops strategy Character dev check for data select Discontinue a stream output op stop

  17. Driver/Kernel Interface • Drivers separate from rest of kernel • Kernel makes calls on specific functions, drivers implement them • Drivers use other kernel functions for: – Device allocation – Resource (e.g., memory) allocation – Scheduling – Etc. (Varies from OS to OS)

  18. Reconfigurable Drivers System call interface open(){…} read(){…} Entry Points for Device j etc. Other Other Driver for Device j kernel services kernel services

  19. NT Driver Organization Data Flow I/O Portion of Native API File System Driver NT Executive Filter Driver I/O Manager Intermediate Driver Filter Driver Device Driver HAL Device

  20. NT Device Drivers • API model is the same as 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

  21. Serial Communication Device Driver •Set UART parms •read/write ops •Interrupt hander UART •parity Controller •bits per byte •etc. RS-232 •9-pin connector •4-wires Modem •bit serial •etc.

  22. Rotating Magnetic Media Track/Cylinder Storage media Sector (Block) Read/write heads

  23. MS Disk Geometry 0x00 0x02 <a jump instruction to 0x1e> 0x03 0x0a Computer manufacturer name 0x0b 0x0c Sectors per cluster (discussed in Exercise 11) 0x0d 0x0f Reserved sectors for the boot record 0x10 0x10 Number of FATs 0x11 0x12 Number of root directory entries 0x13 0x14 Number of logical sectors 0x15 0x15 Medium descriptor byte (used only on old versions of MS-DOS) 0x16 0x17 Sectors per FAT 0x18 0x19 Sectors per track 0x1a 0x1b Number of surfaces (heads) 0x1c 0x1d Number of hidden sectors 0x1e … Bootstrap program

  24. Disk Delays & Optimizations • Disk seek time: Delay while R/W head moves to the destination track/cylinder • Disk latency time: Delay waiting for proper sector to rotate under R/W head • Transfer time: Time to copy bits from disk surface to memory • Access time = seek + latency + transfer

  25. 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

  26. 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

  27. 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

Recommend


More recommend