Quiz 8, Q&A

Q. Explain device drivers as a I/O Software Layer?


A. Drivers (originally) compiled into the kernel. Device installers were technicians. Number and types of devices rarely changed. Nowadays they are dynamically loaded when needed. Linux modules. Drivers classified into similar catagories; Block devices and character (stream of data) device. OS defines a standard (internal) interface to the different classes of devices. Device drivers job; translate request through the device-independent standard interface (open, close, read, write) into appropriate sequence of commands (register manipulations) for the particular hardware. Initialise the hardware at boot time, and shut it down cleanly at shutdown.

Drivers are reentrant as they can be called by another process while a process is already blocked in the driver. Reentrant: Code that can be executed by more than one thread (or CPU) at the same time. Manages concurrency using synch primitives.

Q. What are the disk scheduling algorithms. Explain. Give example.











Time required to read or write a disk block determined by 3 factors; Seek time, Rotational delay, Actual transfer time.

Seek time dominates.

First-in, First-out (FIFO); Process requests as they come. Fair (no starvation). Good for a few processes with clustered requests.

Shortest Seek Time First; Select request that minimises the seek time. Generally performs much better than FIFO. May lead to starvation

Elevator Algorithm (SCAN); Move head in one direction; Services requests in track order until it reaches the last track, then reverses direction. Better than FIFO, usually worse than SSTF. Avoids starvation

Modified Elevator (Circular SCAN, C-SCAN); Like elevator, but reads sectors in only one direction; When reaching last track, go back to first track non-stop. Better locality on sequential reads.