device management. serial port serial device serial device memory cpu printer terminal modem mouse...
TRANSCRIPT
Serial Port
RS-232 Interface• 9-pin connector• 4-wires• bit transmit/receive• ...
Serial Device (UART)
UART API•parity•bits per byte•etc.
Device Driver• Set UART parms•read/write ops•Interrupt hander
Software on the CPU
Device Driver API
Bus Interface
Adding a Modem
SerialDevice
SerialDeviceMemoryMemory
CPUCPU
ModemModem
PhonePhone
Switched Telephone NetworkSwitched Telephone Network
• Dialing & connecting• Convert analog voice to/from digital• Convert bytes to/from bit streams• Transmit/receive protocol
Serial Communication
Modem
RS-232
Serial Device
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
CommDevice
CommDeviceMemoryMemory
CPUCPU
ModemModem
PhonePhone
CommDevice
CommDevice MemoryMemory
CPUCPU
ModemModem
PhonePhone
Switched Telephone NetworkSwitched Telephone Network
Exploiting the Phone Network
Logical CommunicationLogical Communication
Data Networks
NetworkDevice
NetworkDeviceMemoryMemory
CPUCPU
NetworkDevice
NetworkDevice MemoryMemory
CPUCPU
Data NetworkData Network
Logical CommunicationLogical Communication
• Technology focus includes protocols and software (more on this later … Chapter 15 and beyond ...)
MS Disk Description0x00 0x02 <a jump instruction to 0x1e>0x03 0x0a Computer manufacturer name0x0b 0x0c Sectors per cluster (MS-DOS reads/writes a cluster of sectors)0x0d 0x0f Reserved sectors for the boot record0x10 0x10 Number of FATs0x11 0x12 Number of root directory entries0x13 0x14 Number of logical sectors0x15 0x15 Medium descriptor byte (used only on old versions of MS-DOS)0x16 0x17 Sectors per FAT0x18 0x19 Sectors per track0x1a 0x1b Number of surfaces (heads)0x1c 0x1d Number of hidden sectors0x1e … Bootstrap program
Storage Device
Magnetic Disk
(SCSI)
Controller
Driver• Get disk description• Set SCSI parms•read/write ops• Interrupt hander
SCSI API•commands•bits per byte•etc.
Device Driver API
Device Management Organization
ApplicationProcess
ApplicationProcess
FileManager
FileManager
DeviceDriver
DeviceDriver
Device Controller
CommandCommand StatusStatus DataData
Hardware Interface
System Interface
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 Prepare dev for operationclose No longer using the deviceioctl Character dev specific inforead Character dev input opwrite Character dev output opstrategy Block dev input/output opsselect Character dev check for datastop Discontinue a stream output op
Read with Pollingread(device, …);
Data
Device Controller
CommandCommand StatusStatus DataData
read function
write function
1
2 3 4
5
Hardware Interface
System Interface
Read Using Interruptsread(device, …);
Data
Device Controller
CommandCommand StatusStatus DataData
read driver
write driver
1
2
3
4
5Hardware Interface
System Interface
Device Status Table
DeviceHandler
DeviceHandler
InterruptHandler
InterruptHandler
6
7
8a
8b
9
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
OtherKernel
services
OtherKernel
services
Entry Points for Device j
open(){…}
read(){…}
etc.
System call interface
Driver for Device j
NT Driver Organization
I/O P o rtio n o f N a tiv e A P II/
O M
anag
er
D ev ice D riv e r
NT
Exe
cuti
ve
H A L
In te rm ed ia te D riv e r
F ile S y s tem D riv e r
F ilte r D riv e r
F ilte r D riv e r
D a ta F lo w
D ev ice
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
Memory Mapped I/O
PrimaryMemory
Device 0
Device 1
Device n-1
PrimaryMemory
Device 0
Device 1
Device n-1
Dev
ice
Add
ress
esM
emor
y A
ddre
sses
Mem
ory
Add
ress
es
CPU-I/O Overlap
Variable x Register
Data on device
. . .read(dev_I, “%d”, x);y = f(x). . .
Device dev_IMemory CPU
. . .startRead(dev_I, “%d”, x);. . .While(stillReading()) ;y = f(x). . .
I/O - CPU OverlapApp 1
App 2
I/O Ctlr
t1 t2 t3 t4
App
I/O Ctlr
t1 t2 t3 t4 t5 t6 t7 t8 t9
Overlapping App 1’s I/O with App 2
Overlapping App CPU with its own I/O
BufferingWater CompanyCustomer Office
Water Consumers
Water Producer
Delivering Water
Returning the Empties
• Water bottles are buffers• Office workers consume water from a buffer while water company fills other buffers
Hardware Buffering
ProcessProcess
Controller
Data
Device
ProcessProcess
Controller
B
Device
A
Unbuffered Process reads bi-1
Controller reads bi
Hardware Buffering
ProcessProcess
Controller
Data
Device
ProcessProcess
Controller
B
Device
A
ProcessProcess
Controller
B
Device
A
Unbuffered Process reads bi-1
Controller reads bi
Process reads bi
Controller reads bi+1
Buffering in the Driver
ProcessProcess
Controller
B
Device
A
ProcessProcess
Controller
B
Device
A
BA BA
Har
dwar
eD
rive
r
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 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: (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