Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


slices are allocated for each of the queues, and a round robin algorithm is used to process the
queue. This ensures that the I/O bandwidth is shared in a fair manner between the different
queues. If the number of queues is bigger than or equal to the number of processes doing simul-
taneous I/O, this implies that the bandwidth is also fairly distributed between the processes.
Some practical problems (like multiple processes being mapped to identical queues, varying
request sizes, different I/O priorities, etc.) make the distribution not completely fair, but basi-
cally, the method achieves its goal to a good extent.

The deadline scheduler was the default scheduler almost up to the end of development of 2.5 but was
replaced with the anticipatory scheduler until 2.6.17. From 2.6.18 onward, the Completely Fair Queuing
scheduler is the default choice.

For reasons of space, I shall not deal with the implementation details of each scheduler. It should be
noted, however, that the deadline scheduler is much less complicated than the anticipatory scheduler but
delivers practically identical performance in most situations.

6.5.9 Implementation of Ioctls


Ioctls permit the use of special device-specific functions that cannot be accessed by normal read and write
operations. This form of support is implemented by means of theioctlsystem call that can be used with
regular files (detailed descriptions of how it is used are provided in the many system programming
manuals).

As expected, the system call is implemented insys_ioctl, but the main work is done invfs_ioctl.
Figure 6-19 shows the associated code flow diagram.

Process standard ioctls

Block devices: blkdef_ioctl

Yes

No

vfs_ioctl

file_ioctl

file->f_op->ioctl

Regular file?

Figure 6-19: Code flow diagram forsys_ioctl.

The desired ioctl is specified by means of a passed constant; typically, symbolic pre-processor constants
are used for this purpose.

Two situations must be distinguished once the kernel has checked whether one of the standard ioctls has
been applied (these are available for all files in the system regardless of type); for example, whether the
file descriptor is to be closed whenexecis executed (see Chapter 2).
Free download pdf