CS350-02c-dev-mgmt

Download Report

Transcript CS350-02c-dev-mgmt

Device Mgmt
© 2004, D. J. Foreman
1
Device Management Organization
 Multiple
layers
Application
■ Operating System
■ Driver
■ Controller
■ Device
■
 Tradeoffs
■
■
■
of layering
Loss of efficiency
Increased generalization and flexibility
Reduced cost of maintenance and development for all
(driver writers, O/S writers, app writers and users)
© 2004, D. J. Foreman
2
Device Management Organization-2
Applications
read,
write
read,
write
read,
write
API
Device
independent
Device
Driver
Device
Driver
Device
Driver
O/S
Device
dependent
Controller
Firmware
Devices
© 2004, D. J. Foreman
3
The API
 Simple
■
read, write, seek, control
 Direct
■
vs Sequential
Disks vs tapes, printers, etc
 Block
■
set of abstract I/O operations
vs Character
Disk vs keyboard
 Blocking
vs Non-blocking
Synchronous - request I/O & wait for it
■ Asynchronous - request I/O & continue to run
■
© 2004, D. J. Foreman
4
Handling I/O
 Polling
Program loops until device signals completion
■ No other program can run
■ CPU runs, but no work gets done!
■
 Interrupt
driven
Program starts I/O
■ Program decides to wait or not
■ O/S switches to another thread or process
■
© 2004, D. J. Foreman
5
Key concepts
 CPU
cycles are wasted during an I/O wait
 Devices are independent of CPU
 Why
not overlap I/O with CPU?
Program can decide when to wait
■ System throughput can be increased
■
© 2004, D. J. Foreman
6
Driver/Kernel Interface
 Drivers
may be merged with kernel
 Kernel makes function calls to drivers
 Kernel functions used by drivers:
Device allocation
■ Resource (e.g., memory) allocation
■ Scheduling
■ Others: depends on O/S
■
© 2004, D. J. Foreman
7
System bottlenecks
 Compute
bound processes
very little I/O activity
■ nothing else runs until time-slice used up
■
 I/O
■
bound processes
very little CPU activity
 Solution:
"Good" mix of applications
■ Pre-emptive scheduling (more later)
■
© 2004, D. J. Foreman
8
Overlapped I/O
th1's time
slice ends
th0
P1
Apps
th1
th1
P2
th1
th1
th2
th2
Device
t1
Blockin
g I/O
© 2004, D. J. Foreman
t2 t3 t4
t5
t6
NonBlockin
g I/O
t7
t8
t9
th1 & th2
overlapping
9
Buffering
 Provides
a means for speed-matching
 Many methods
■
Lists
• 1 way, 2 way, circular
■
Arrays
• Fixed size
• Variable size
• Circular
 Problems
■
■
■
Overflow
Protected access
Synchronization – more in another chapter
© 2004, D. J. Foreman
10
Example of using buffers
Customer Office
Water Company
Returning the Empties
Water Producer
Water Consumers
Production
qty?
Delivering Water
Consumption
qty?
Inventory
Classic "Producer-Consumer"
© 2004, D. J. Foreman
11
Hardware Buffering
 In
the Device controller
 In the Device itself = "double-buffering"
 Reduces system overhead from:
Buffer mgmt
■ Buffer content
■ Synchronizing
■
© 2004, D. J. Foreman
12
Disk I/O
 Goal
■
– minimize access time
Mixed solution: h/w & s/w
= (X + Y*K) + latency + transfer
 Seek time: head movement delay
■
■
for 1 cylinder (X) ≈ 10 ms
For Y cylinders = Y * K
 Latency:
■
■
rotational delay
5400R/M*1M/60s= 90R/s  .01 s/R = 10ms/R
7200 R/M*1M/60s=120R/s  .008 s/R= 8ms/R
 Transfer
■
(device dependent)
(K is device dependent)
time: delay between disk and RAM
Bus speed (currently) 400 Mhz or 800 Mhz
 Access
© 2004, D. J. Foreman
Time = seek + latency + transfer
13
Access Algorithms
 FCFS
■
No optimization
 SSTF
■
– min seek from current position
Starvation can occur (from local minimization)
 Scan/Look
No starvation
■ Requests may wait a full scan (0-n-0)
■
 Circular
Scan/Look
No starvation
■ Requires fast-reposition to 0
■
© 2004, D. J. Foreman
14
Serial I/O
 Must
convert
Parallel (bytes) to serial (bit-by-bit)
■ Digital (1/0) to analog (+/- voltages)
■
 And
back again at the other end
 Protocol:
© 2004, D. J. Foreman
RS-232
15
Mainframe Device Mgmt
CPU
Channel
Controller
Hardware
Devices
© 2004, D. J. Foreman
16
Channel programming
SIO
devaddr
Channel Program
Seek
Channel Address Word
Search
Read/write
Device
© 2004, D. J. Foreman
17