190 likes | 382 Views
CSI 400/500 Operating Systems Spring 2009. Lecture #14 – Device Management and Drivers Monday, March 23 rd , 2009. Device Manager. Handles communication between Operating System and external devices Contains collection of device drivers
E N D
CSI 400/500 Operating SystemsSpring 2009 Lecture #14 – Device Management and Drivers Monday, March 23rd, 2009
Device Manager • Handles communication between Operating System and external devices • Contains collection of device drivers • Contains library of interrupt handlers for device conditions
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
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
Buffering • Maintaining data in repository before needed • Input buffers facilitate speedier processing • Output buffers prevents suspends for slow transfer rate
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
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
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
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_()
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
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
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
Sysfs • User space “copy” of kernel’s device model • File system for device model interfaces • Contains file descriptors and device driver specifications
Kobjects • Data abstraction of device properties • Things like usage counts, parameters, and object type • Main fields: • Kref : maintains reference count • Kset pointer • Kobj_type
Device classes • Class inheritance chain of device drivers • Top level classes: • Bus • Class • Device • Devices are categorized as input, output, and data
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