CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday,...

Preview:

Citation preview

CSI 400/500 Operating SystemsSpring 2009

Lecture #14 – Device Management and DriversMonday, March 23rd, 2009

2

Device Manager Handles communication between

Operating System and external devices

Contains collection of device drivers

Contains library of interrupt handlers for device conditions

3

Device Driver Library of functions controlling

access to device Contains functions like read, write,

open, close, seek, ping, pipe, etc. Involved through system calls

Device Independence Standard set of operations

common to all devices If no device specified, OS

determines best available device to perform operation

4

Reconfigurable Device Drivers Addition of device without

restarting operating system MS Windows has this capacity

when it senses new hardware You install a driver and it’s added

to the library automatically

5

6

Buffering Maintaining data in repository

before needed Input buffers facilitate speedier

processing Output buffers prevents suspends for

slow transfer rate

7

Multiple Buffer Methods Double buffer

The device has one buffer while the device driver has another

Allows for data passing back and forth without interference

Circular buffers Multiple buffers for each device and driver Prevents backlog of data Order of transmission becomes important

8

Device Types Device Managers catalog drivers based

upon type Communication devices

We’ll discuss these further in the networking topic

Storage devices Sequential access: ex. magnetic tape Random access: ex. disk

I/O device Keyboards, mouse, printers, scanners have own

drivers

Device Types, cont Communication Devices

Transfer data between computer and external computer

Requires defined interface Uses a mutually-understood protocol We’ll discuss such protocols later in

the course

9

10

Driver Optimization When writing a device driver,

consider best means to access data: 1st Come, 1st Served (FCFS) Shortest Seek Time (SST) Scan/Look – access in direction

11

Linux Device Management Devices signified by major and

minor numbers Major number is device type Minor number is specific device

Device drivers activated with _init()

Driver interface recognized by operating system by register_()

12

Linux I/O Driver functions Open and close Read, readdir, and write Flush and release (for data buffers) Seek Map Sync lock

Linux Device Models C++ abstract classes Based on commonalities among

drivers Model types:

Udev Sysfs Kobject Device classes

13

Udev User device in /dev Gave device management to user

space Used to be managed by dynamic

node creation That was more tedious, requiring

interaction between kernel and device driver

14

Udev set-up Uses series of daemons and

utilities Has rules that can be constructed

to ease interface with devices Typically used for direct-access

auxiliary storage devices like CD-ROM drives or flash drives

15

Sysfs User space “copy” of kernel’s

device model File system for device model

interfaces Contains file descriptors and device

driver specifications

16

Kobjects Data abstraction of device

properties Things like usage counts, parameters,

and object type Main fields:

Kref : maintains reference count Kset pointer Kobj_type

17

Device classes Class inheritance chain of device

drivers Top level classes:

Bus Class Device

Devices are categorized as input, output, and data

18

Plugged devices Coldplugged

Devices that were connected at system boot time

Hotplugged Devices installed since boot Device drivers considered “on the fly” Not stored in same directory Maintained as interrupt processing

19

Recommended