6.1 Fewer States
The device model can be simplified by reducing the number of states
that the device can be in. Look for states that, from the
software's perspective, are only there to optimize performance.
Here are some examples:
- SCSI devices can become disconnected, and when disconnected they
behave differently than when connected. In most cases, we can
ignore the disconnected state, and let the device be connected all
- Some network devices can be put in "early interrupt" mode, where
interrupts are sent some time before a buffer fills up, to give the
driver more time to handle the data. It may be possible to ignore
the early interrupt state, if the driver can handle the load
anyway. In this case, it is a good idea to warn the user when the
driver tries to put the device in early interrupt mode.
- Some devices cache data to speed things up, and provide some means
to query whether the cached value is valid. The simplest way to
model this is to ignore this state, and always report "no, the
cache is not valid".