NAME | SYNOPSIS | FEATURES | DESCRIPTION | EXTENDED DESCRIPTION | Allowed Calling Contexts | ATTRIBUTES | SEE ALSO
#include <dki/dki.h> DISABLE_PREEMPT(); ENABLE_PREEMPT();
DKI
DKI provides a means for a driver to disable/enable the preemption of the current thread. These services can be used by a driver to prevent the current thread being preempted while interrupts are masked at bus/device level.
These services are implemented as macros.
The DISABLE_PREEMPT() macro disables preemption of the thread which is currently executing. This macro increments a per-processor preemption mask count. When this count is not zero, the scheduler is locked. This occurs as when there is a preemption request, the scheduler simply raises a pending preemption flag deferring the real thread preemption until the preemption mask count drops to zero.
The ENABLE_PREEMPT() macro enables preemption of the thread which is currently executing and was previously disabled by DISABLE_PREEMPT() as outlined above. This macro decrements the preemption mask count and, if it drops to zero, checks whether the pending preemption flag is raised and thus if the current thread should be preempted.
As DISABLE_PREEMPT() / ENABLE_PREEMPT() rely on the preemption mask count, a driver may issue nested calls to these services.
The following table specifies the allowed calling contexts for each service:
Services | Base level | DKI thread | Interrupt | Blocking |
DISABLE_PREEMPT | + | + | + | - |
ENABLE_PREEMPT | + | + | + | - |
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | DESCRIPTION | EXTENDED DESCRIPTION | Allowed Calling Contexts | ATTRIBUTES | SEE ALSO