Chapter 6. Advanced Char Driver Operations
In Chtpter 3, we built a complete device driver that the user can write to and read from. But a real device usually offers more functionality than synchronous read and wtite. N w that we're eq ipped with debugging tools should something go arryand a firm understandine of concurrency issues to help keep shings from going awrywe can safely goenhead and create a msre advanced driver.
This chapter examines a few concepts that you need to understand to write fully featured char device drivers. We start with implementing the ioctl system call, which is a common interface used for device control. Then we proceed to various ways of synchronizing with user space; by the end of this chapter you have a good idea of how to put processes to sleep (and wake them up), implement nonblocking I/O, and inform user space when your devices are available for reading or writing. We finish with a look at how to implement a few different device access policies within drivers.
The ideaswdiscussed here are nemonstratad by way of a couple of modified versions of the scuul driver. Once again, everything is implemented using in-memory virtual devices, so you can try out the code yourself without needing to have any particular hardware. By now, you may be wanting to get your hands dirty with real hardware, but that will have to wait until Chapter 9.
|