Device Management Serial Port CPU Memory Serial Device

  • Slides: 34
Download presentation
Device Management

Device Management

Serial Port CPU Memory Serial Device • Printer • Terminal • Modem • Mouse

Serial Port CPU Memory Serial Device • Printer • Terminal • Modem • Mouse • etc.

Serial Port Device Driver API Device Driver Software on the CPU • Set UART

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

Adding a Modem CPU Memory Serial Device Modem • Dialing & connecting • Convert

Adding a Modem CPU Memory Serial Device Modem • Dialing & connecting • Convert analog voice to/from digital • Convert bytes to/from bit streams • Transmit/receive protocol Phone Switched Telephone Network

Serial Communication Device Driver • Set UART parms • read/write ops • Interrupt hander

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

Exploiting the Phone Network Logical Communication CPU Memory CPU Comm Device Modem Phone Switched

Exploiting the Phone Network Logical Communication CPU Memory CPU Comm Device Modem Phone Switched Telephone Network Memory

Data Networks • Technology focus includes protocols and software (more on this later …

Data Networks • Technology focus includes protocols and software (more on this later … Chapter 15 and beyond. . . ) Logical Communication CPU Memory Network Device Data Network CPU Memory

Rotating Storage Sec tor Track (Cylinder) Top View of a Surface

Rotating Storage Sec tor Track (Cylinder) Top View of a Surface

MS Disk Description

MS Disk Description

Storage Device Driver API Driver • Get disk description • Set SCSI parms •

Storage 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

Device Management Organization Application Process System Interface File Manager Device Driver Hardware Interface Command

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

System Call Interface • Functions available to application programs • Abstract all devices (and

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)

Example: BSD UNIX Driver open close ioctl read write strategy select stop Prepare dev

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

Read with Polling read(device, …); 1 System Interface Data read function 5 write function

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

Read Using Interrupts read(device, …); 1 9 8 b Data System Interface Device Status

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

Driver-Kernel Interface • Drivers are distinct from main part of kernel • Kernel makes

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)

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

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

NT Driver Organization

NT Driver Organization

NT Device Drivers • API model is the same as for a file •

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

Primary Memory Device Addresses Device 0 Device 1 Device n-1 Primary Memory Addresses Memory

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

CPU-I/O Overlap. . . read(dev_I, “%d”, x); y = f(x). . . start. Read(dev_I,

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

I/O - CPU Overlap App 1 App 2 I/O Ctlr t 1 t 2

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 Overlapping App CPU with its own I/O t 9

Direct Memory Access Primary Memory CPU Controller Device

Direct Memory Access Primary Memory CPU Controller Device

Buffering Customer Office Water Company Returning the Empties Water Producer Water Consumers Delivering Water

Buffering Customer Office Water Company Returning the Empties Water Producer Water Consumers Delivering Water • Water bottles are buffers • Office workers consume water from a buffer while water company fills other buffers

Hardware Buffering Process Controller Data A Device Unbuffered B Process reads bi-1 Controller reads

Hardware Buffering Process Controller Data A Device Unbuffered B Process reads bi-1 Controller reads bi

Hardware Buffering Process Controller Data A Device Unbuffered Process B Process reads bi-1 Controller

Hardware Buffering Process Controller Data A Device Unbuffered Process B Process reads bi-1 Controller reads bi A B Device Process reads bi Controller reads bi+1

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

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

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

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

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

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

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

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

Disk Optimizations • Transfer Time: Time to copy bits from disk surface to memory

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

Optimizing Seek Time • Multiprogramming on I/O-bound programs => set of processes waiting for

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

Optimizing Seek Time (cont) • Requests = 23, 87, 36, 93, 66 • SSTF:

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 + 33 + 30 + 13 = 100 steps • Look: (75), 87, 93, 66, 36, 23 – 12 + 6 + 27 + 30 + 13 = 87 steps

Optimizing Seek Time (cont) • Requests = 23, 87, 36, 93, 66 • Circular

Optimizing Seek Time (cont) • Requests = 23, 87, 36, 93, 66 • Circular Scan: (75), 87, 93, 99, 23, 36, 66 – 12 + 6 + home + 23 + 13 + 30 = 90 + home • Circular Look: (75), 87, 93, 23, 36, 66 – 12 + 6 + home + 23 + 13 + 30 = 84 + home