Specifications

Understanding Device Drivers
2-3
System data structures, called switch tables, contain the starting addresses for the principal
routines included in all drivers. Switch tables contain a row for each driver, and a column
for each standard routine. Standard routines are collectively named “entry-point routines”,
referring to the memory address where executions begins. The kernel translates the argu-
ments of the system call into a value used as an index into the switch table.
For example, a user process issues a system call to open a file. The kernel directs the
request to the switch table entry for the open routine of the device driver for the device
that contains the file (see Figure 2-2). The request executes the routine, either giving the
user process access to the file or returning an error code to the kernel.
Figure 2-2. How the System Calls Driver Routines
Parallel Execution 2
When a traditional single-threaded application program runs, the statements making up
the program execute one at a time; in sequential order. Program control structures (loops
and branches) repeat statements and can branch to alternative sections of code, but at any
given instant only one statement and one routine executes. This is true even of different
instances of a program being run by two users at the same time (for example, a text editor).
As each process receives a scheduled slice of CPU time, the statements execute in the
order maintained for that invocation of the program.
Drivers, however, form part of the kernel and must run instantly at the request of many
processes. A driver might receive a request to write data to a disk while waiting for a pre-
vious request to complete. The design of the driver code must specifically enable it to
respond to numerous requests without creating a separate executable image of itself for
each request (unlike a text editor.) The driver does not create a new instance of itself (and
its data structures) for each process, so it must resolve contention problems resulting from
overlapping I/O requests.
Interrupts 2
Device drivers spend most of their execution time moving data between user address space
and a hardware device, such as a disk drive or terminal. Because hardware devices work
User Issues
System Call To
Open Device
open
open
open
close A
B
C
close
close
• • •
• • •
• • •
Driver A
open Routine
Driver B
open Routine
Driver C
open Routine
Device A
Device B
Device C
160980