csi 400/500 operating systems spring 2009 lecture #14 – device management and drivers monday,...

19
CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd , 2009

Upload: jakayla-bearer

Post on 30-Mar-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

CSI 400/500 Operating SystemsSpring 2009

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

Page 2: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 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

Page 3: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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

Page 4: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

Device Independence Standard set of operations

common to all devices If no device specified, OS

determines best available device to perform operation

4

Page 5: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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

Page 6: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

6

Buffering Maintaining data in repository

before needed Input buffers facilitate speedier

processing Output buffers prevents suspends for

slow transfer rate

Page 7: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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

Page 8: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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

Page 9: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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

Page 10: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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

Page 11: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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_()

Page 12: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

12

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

Page 13: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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

drivers Model types:

Udev Sysfs Kobject Device classes

13

Page 14: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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

Page 15: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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

Page 16: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

Sysfs User space “copy” of kernel’s

device model File system for device model

interfaces Contains file descriptors and device

driver specifications

16

Page 17: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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

Page 18: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

Device classes Class inheritance chain of device

drivers Top level classes:

Bus Class Device

Devices are categorized as input, output, and data

18

Page 19: CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009

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