18
© 2004, D. J. Foreman 1 Device Mgmt

© 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization Multiple layers ■ Application ■ Operating System ■ Driver

Embed Size (px)

DESCRIPTION

© 2004, D. J. Foreman 3 Device Management Organization-2 O/S API Applications Controller Firmware Devices Device Driver Device independent Device dependent read, write

Citation preview

Page 1: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 1

Device Mgmt

Page 2: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 2

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)

Page 3: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 3

Device Management Organization-2

O/S

API

Applications

ControllerFirmware

Devices

DeviceDriver

DeviceDriver

DeviceDriver

Deviceindependent

Devicedependent

read,write

read,write

read,write

Page 4: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 4

The APISimple set of abstract operations

■ read, write, seek, control

Direct vs Sequential■ Disks vs tapes, printers, etc

Block vs Character■ Disk vs keyboard

Blocking vs Non-blocking

Page 5: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 5

Handling I/OPolling

■ 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

Page 6: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 6

Key conceptsCPU cycles are wasted during a waitDevices are independentMultitasking (or threading) is possibleWhy not overlap I/O with CPUThreads can decide when to waitNon-thread programs can also decideSystem throughput is increased

Page 7: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 7

Driver/Kernel InterfaceDrivers merged with kernelKernel makes function calls to driversKernel functions used by drivers:

■ Device allocation■ Resource (e.g., memory) allocation■ Scheduling■ Others: depends on O/S

Page 8: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 8

System bottlenecksCompute bound processes

■ no devices get started until time-slice used up■ Only one process/thread gets service

I/O bound processes■ CPU under-utilized

Solution:■ "Good" mix of applications■ Pre-emptive scheduling (more later)

Page 9: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 9

Overlapped I/O

Apps

t1 t2 t3 t4 t5 t6 t7 t8 t9

Device

th1 th1 th1 th1 th1

Blocking I/O

Non-Blocking I/O

th2 th2

P1

P2

Page 10: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 10

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

Page 11: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 11

Example of using buffers

Water CompanyCustomer Office

Water Consumers

Water Producer

Delivering Water

Returning the Empties

Production qty?

Consumption qty?

Inventory

Classic "Producer-Consumer"

Page 12: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 12

Hardware BufferingIn the Device controllerIn the Device itself = "double-buffering"Reduces system overhead from:

■ Buffer mgmt■ Buffer content■ Synchronizing

Page 13: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 13

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 (device dependent)■ For Y cylinders = Y * K (K is device dependent)

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 time: delay between disk and RAM■ Bus speed (currently) 400 Mhz or 800 Mhz

Access Time = seek + latency + transfer

Page 14: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 14

Access AlgorithmsFCFS

■ No optimizationSSTF – 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

Page 15: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 15

Serial I/OMust convert

■ Parallel (bytes) to serial (bit-by-bit)■ Digital (1/0) to analog (+/- voltages)

And back again at the other end

Protocol: RS-232

Page 16: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 16

MS-bootable disk layout0x00-0x02 jump inst to 0x1e0x03-0x0a PC manufacturer name0x0b-0x0c sectors/cluster0x0d-0x0f reserved for boot record0x10-0x10 # of FAT's0x11-0x12 # root directory entries0x13-0x14 # logical sectors0x15-0x15 media descriptor0x16-0x17 sectors/FAT0x18-0x19 sectors/track0x1a-0x10b # surfaces (heads)0x1c-0x1d # hidden sectors0x1e-… boot program

Page 17: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 17

Mainframe Device Mgmt

CPU

Channel

ControllerHardware

Devices

Page 18: © 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver

© 2004, D. J. Foreman 18

Channel programming

SIO devaddr

Channel Address Word

Channel Program

Seek

Search

Read/write

Device