Certain DDI mechanisms provide a callback mechanism. DDI functions provide a mechanism for scheduling a callback when a condition is met. Callback functions can be used for the following typical conditions:
A transfer has completed
A resource has become available
A time-out period has expired
Callback functions are somewhat similar to entry points, for example, interrupt handlers. DDI functions that allow callbacks expect the callback function to perform certain tasks. In the case of DMA routines, a callback function must return a value indicating whether the callback function needs to be rescheduled in case of a failure.
Callback functions execute as a separate interrupt thread. Callbacks must handle all the usual multithreading issues.
A driver must cancel all scheduled callback functions before detaching a device.