Writing Device Drivers

Flow of Control

These interfaces influence the flow of program control in a driver. These are mostly callback mechanisms, functions that schedule another function to run at a later time. Many drivers schedule a function to run intermittently to check on the status of the device, and possibly issue an error message if a strange condition is detected.

Note -

The detach(9E) entry point must ensure that no callback functions are pending in the driver before returning successfully. See Chapter 5, Autoconfiguration.

timeout_id_t timeout(void (*ftn)(caddr_t), caddr_t arg, clock_t ticks);
timeout(9F) schedules the function pointed to by ftn to be run after ticks clock ticks have elapsed. arg is passed to the function when it is run. timeout(9F) returns a "timeout ID" that can be used to cancel the timeout later.

int untimeout(timeout_id_t id);
untimeout(9F) cancels the timeout indicated by the timeout ID id. If the number of clock ticks orignially specified to timeout(9F) have not elapsed, the callback function will not be called.