|
|
Drivers need to deal with various synchronization and timing issues, and both DDI and ODDI provide facilities for these. For a full reference list of the facilities that are provided, see ``Synchronization primitives''.
DDI drivers use synchronization variables, described in ``Synchronization variables''. That article also includes a comparison of synchronization with the older sleep(D3) and wakeup(D3) mechanisms.
ODDI drivers use sleep(D3oddi) to block the driver, and wakeupn(D3oddi) to unblock a single process that is waiting for that event or wakeup(D3oddi) to unblock all processes that are waiting for that event.
Critical code is usually protected with spin locks, where a lock is set and any other code that attempts to access that region spins until the resource is available. DDI spin locks are discussed in ``Spin locks (DDI)''; ODDI spin locks are discusssed in ``Spin locks (ODDI)''.
Both DDI and ODDI also support the spl( ) function, which controls the interrupt-driven code that can execute and could prevent the critical code from executing atomically. See spl(D3) and spl(D3oddi).