Device Management Device Management Organization Application - - PowerPoint PPT Presentation

device management device management organization
SMART_READER_LITE
LIVE PREVIEW

Device Management Device Management Organization Application - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

Device Management

slide-2
SLIDE 2

Device Management Organization

Application Process Application Process File Manager File Manager Device Driver Device Driver Device Controller

Command Command Status Status Data Data

Hardware Interface API

slide-3
SLIDE 3

Read with Polling

read(device, …); Data

Device Controller

Command Command Status Status Data Data read function write function 1 2 3 4 5

Hardware Interface System Interface

slide-4
SLIDE 4

Read with Interrupts

read(device, …); Data

Device Controller

Command Command Status Status Data Data read driver write driver 1 2 3 4 5

Hardware Interface System Interface

Device Status Table Device Handler Device Handler Interrupt Handler Interrupt Handler 6 7 8a 8b 9

slide-5
SLIDE 5

CPU-I/O Overlap

Variable x Register

Data on device

. . . read(dev_I, “%d”, x); y = f(x) . . .

Device dev_I Memory CPU

. . . startRead(dev_I, “%d”, x); . . . While(stillReading()) ; y = f(x) . . .

slide-6
SLIDE 6

I/O - CPU Overlap

App 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

slide-7
SLIDE 7

Memory Mapped I/O

Primary Memory

Device 0 Device 1 Device n-1

Primary Memory

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

slide-8
SLIDE 8

Direct Memory Access

Primary Memory CPU Controller Device Primary Memory CPU Controller Device

slide-9
SLIDE 9

Hardware Buffering

Process Process Controller Data Device Process Process Controller B Device A

Unbuffered Process reads bi-1 Controller reads bi

slide-10
SLIDE 10

Hardware Buffering

Process Process Controller Data Device Process Process Controller B Device A Process Process Controller B Device A

Unbuffered Process reads bi-1 Controller reads bi Process reads bi Controller reads bi+1

slide-11
SLIDE 11

Buffering in the Driver

Process Process Controller B Device A B A

Hardware Driver

slide-12
SLIDE 12

Buffering in the Driver

Process Process Controller B Device A Process Process Controller B Device A B A B A

Hardware Driver

slide-13
SLIDE 13

A Ring Buffer

From data producer To data consumer Buffer i Buffer j

slide-14
SLIDE 14

Compute vs. I/O Bound

Compute-bound I/O-bound Time

slide-15
SLIDE 15

Application Programming Interface

  • Functions available to application programs
  • Abstract all devices 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)

slide-16
SLIDE 16

BSD UNIX Driver

  • pen

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

slide-17
SLIDE 17

Driver/Kernel Interface

  • Drivers separate from rest of kernel
  • Kernel makes calls on specific functions,

drivers implement them

  • Drivers use other kernel functions for:

– Device allocation – Resource (e.g., memory) allocation – Scheduling – Etc. (Varies from OS to OS)

slide-18
SLIDE 18

Reconfigurable Drivers

Other kernel services Other kernel services Entry Points for Device j

  • pen(){…}

read(){…}

etc. System call interface Driver for Device j

slide-19
SLIDE 19

NT Driver Organization

I/O Portion of Native API I/O Manager Device Driver NT Executive HAL Intermediate Driver File System Driver Filter Driver Filter Driver Data Flow Device

slide-20
SLIDE 20

NT Device Drivers

  • API model is the same as 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
slide-21
SLIDE 21

Serial Communication Device

Modem RS-232

  • 9-pin connector
  • 4-wires
  • bit serial
  • etc.

Controller UART

  • parity
  • bits per byte
  • etc.

Driver

  • Set UART parms
  • read/write ops
  • Interrupt hander
slide-22
SLIDE 22

Rotating Magnetic Media

Sector (Block) Storage media Read/write heads Track/Cylinder

slide-23
SLIDE 23

MS Disk Geometry

0x00 0x02 <a jump instruction to 0x1e> 0x03 0x0a Computer manufacturer name 0x0b 0x0c Sectors per cluster (discussed in Exercise 11) 0x0d 0x0f Reserved sectors for the boot record 0x10 0x10 Number of FATs 0x11 0x12 Number of root directory entries 0x13 0x14 Number of logical sectors 0x15 0x15 Medium descriptor byte (used only on old versions of MS-DOS) 0x16 0x17 Sectors per FAT 0x18 0x19 Sectors per track 0x1a 0x1b Number of surfaces (heads) 0x1c 0x1d Number of hidden sectors 0x1e … Bootstrap program

slide-24
SLIDE 24

Disk Delays & Optimizations

  • Disk seek time: Delay while R/W head

moves to the destination track/cylinder

  • Disk latency time: Delay waiting for proper

sector to rotate under R/W head

  • Transfer time: Time to copy bits from disk

surface to memory

  • Access time = seek + latency + transfer
slide-25
SLIDE 25

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
slide-26
SLIDE 26

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

slide-27
SLIDE 27

Optimizing 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