Interrupt handlers and other asynchronous callback functions require special care by the module writer, since they can execute asynchronously to threads executing within the module open, close, put, and service procedures.
For modules using perimeters, use qtimeout(9F) and qbufcall(9F) instead of timeout(9F) and bufcall(9F). The qtimeout and qbufcall callbacks are synchronous and consequently introduce no special synchronization requirements.
Since a thread can enter the module at any time, you must ensure that the asynchronous callback function acquires the proper private locks before accessing private module data structures, and releases these locks before returning. You must cancel any outstanding registered callback routines before the data structures on which the callback routines depend are deallocated and the module closed.
For hardware device interrupts, this involves disabling the device interrupts.
The module cannot hold certain private locks across calls to untimeout(9F) or unbufcall(9F). These locks are those which the module's timeout(9F) or bufcall(9F) callback functions acquire. See "MT SAFE Modules Using Explicit Locks".
Outstanding callbacks from esballoc(9F), if associated with a particular Stream, must be allowed to complete before the module close routine deallocates those private data structures on which they depend.