Title: Device Management
1Device Management
2Serial Port
CPU
Serial Device
Memory
- Printer
- Terminal
- Modem
- Mouse
- etc.
3Serial Port
Device Driver API
- Device Driver
- Set UART parms
- read/write ops
- Interrupt hander
Software on the CPU
Bus Interface
Serial Device (UART)
- UART API
- parity
- bits per byte
- etc.
- RS-232 Interface
- 9-pin connector
- 4-wires
- bit transmit/receive
- ...
4Adding a Modem
CPU
- Dialing connecting
- Convert analog voice to/from digital
- Convert bytes to/from bit streams
- Transmit/receive protocol
Serial Device
Memory
Modem
Phone
Switched Telephone Network
5Serial 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
6Exploiting the Phone Network
Logical Communication
CPU
CPU
Comm Device
Memory
Comm Device
Memory
Modem
Modem
Phone
Phone
Switched Telephone Network
7Data Networks
- Technology focus includes protocols and software
- (more on this later Chapter 15 and beyond
...)
Logical Communication
CPU
CPU
Network Device
Memory
Network Device
Memory
Data Network
8Rotating Storage
Track (Cylinder)
Sector
Top View of a Surface
9MS Disk Description
10Storage 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
11Device Management Organization
Application Process
System Interface
File Manager
Device Driver
Hardware Interface
Command
Status
Data
Device Controller
12System 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)
13Example 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
14Read with Polling
read(device, )
Data
1
System Interface
read function
5
write function
2
3
4
Hardware Interface
Command
Status
Data
Device Controller
15Read Using Interrupts
read(device, )
9
1
8b
Data
System Interface
Device Status Table
4
7
Device Handler
read driver
write driver
2
6
3
8a
Interrupt Handler
5
Hardware Interface
Command
Status
Data
Device Controller
16Driver-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)
17Reconfigurable Drivers
System call interface
open()
read()
Entry Points for Device j
etc.
Other Kernel services
Driver for Device j
18NT Driver Organization
19NT 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
20Memory Mapped I/O
Primary Memory
Primary Memory
Memory Addresses
Device 0
Device 0
Memory Addresses
Device 1
Device 1
Device Addresses
Device n-1
Device n-1
21CPU-I/O Overlap
. . . 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
22I/O - CPU Overlap
App 1
App 2
I/O Ctlr
t1
t2
t3
t4
Overlapping App 1s I/O with App 2
App
I/O Ctlr
t1
t2
t3
t4
t5
t6
t7
t8
t9
Overlapping App CPU with its own I/O
23Direct Memory Access
Primary Memory
Primary Memory
CPU
CPU
Controller
Controller
Device
Device
24Buffering
Water Company
Customer Office
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
25Hardware Buffering
Process
Process
Controller
Controller
Data
B
A
Device
Device
Process reads bi-1 Controller reads bi
Unbuffered
26Hardware Buffering
Process
Process
Process
Controller
Controller
Controller
Data
B
A
B
A
Device
Device
Device
Process reads bi-1 Controller reads bi
Process reads bi Controller reads bi1
Unbuffered
27Buffering in the Driver
Process
B
A
Driver
Controller
B
A
Hardware
Device
28Buffering in the Driver
Process
Process
B
A
B
A
Driver
Controller
Controller
B
A
B
A
Hardware
Device
Device
29A Ring Buffer
To data consumer
Buffer i
Buffer j
From data producer
30Compute vs I/O Bound
Compute-bound
Time
I/O-bound
31Disk 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
32Optimizing Seek Time
- Multiprogramming on I/O-bound programs gt set of
processes waiting for disk - Seek time dominates access time gt minimize seek
time across the set - Tracks 099 Head at track 75, requests for 23,
87, 36, 93, 66 - FCFS 52 64 51 57 27 251 steps
33Optimizing 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
34Optimizing 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