Writing Device Drivers

Adaptive Strategies

A driver can continue to provide a service with faulty hardware, attempting to work around the identified problem by using an alternative strategy for accessing the device. Given the unpredictability of broken hardware and the risk associated with additional design complexity, adaptive strategies are not always wise. At most, they should be limited to periodic interrupt polling and retry attempts. Periodically retrying the device lets the driver know when a device has recovered. Periodic polling can control the interrupt mechanism, after a driver has been forced to disable interrupts.

Ideally, a system always has an alternative device to provide a vital system service. Service multiplexors in kernel or user space offer the best method of maintaining system services when a device fails. Such practices are beyond the scope of this appendix.