Export (0) Print
Expand All
Expand Minimize

KeDelayExecutionThread routine

The KeDelayExecutionThread routine puts the current thread into an alertable or nonalertable wait state for a specified interval.


NTSTATUS KeDelayExecutionThread(
  _In_  BOOLEAN Alertable,
  _In_  PLARGE_INTEGER Interval


WaitMode [in]

Specifies the processor mode in which the caller is waiting, which can be either KernelMode or UserMode. Lower-level drivers should specify KernelMode.

Alertable [in]

Specifies TRUE if the wait is alertable. Lower-level drivers should specify FALSE.

Interval [in]

Specifies the absolute or relative time, in units of 100 nanoseconds, for which the wait is to occur. A negative value indicates relative time. Absolute expiration times track any changes in system time; relative expiration times are not affected by system time changes.

Return value

KeDelayExecutionThread returns one of the following values that describes how the delay was completed:

Return codeDescription

The delay completed because the specified interval elapsed.


The delay completed because the thread was alerted.


A user-mode APC was delivered before the specified Interval expired.




The expiration time is computed and the current thread is put in a wait state. When the specified interval has passed, the thread exits the wait state and is put in the ready state, becoming eligible for execution.


If the WaitMode parameter is UserMode, the kernel stack can be swapped out during the wait. Consequently, a caller must never attempt to pass parameters on the stack when calling KeDelayExecutionThread using the UserMode argument.

It is especially important to check the return value of KeDelayExecutionThread when the WaitMode parameter is UserMode or Alertable is TRUE, because KeDelayExecutionThread might return early with a status of STATUS_USER_APC or STATUS_ALERTED.


Where possible, Alertable should be set to FALSE and WaitMode should be set to KernelMode, in order to reduce driver complexity. The principal exception to this guideline is when the wait is a long-term wait.

The expiration time of the delay is expressed as either an absolute time at which the delay is to expire, or a time relative to the current system time. If the Interval parameter value is positive, the expiration time is an absolute time. If this value is negative, the expiration time is a relative time.

Expiration times are measured relative to the system clock, and the accuracy with which the operating system can detect when a timer expires is limited by the granularity of the system clock. For more information, see Timer Accuracy.



Available starting with Windows 2000.


Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)





DDI compliance rules

IrqlKeApcLte1, PowerIrpDDis, HwStorPortProhibitedDDIs

See also




Send comments about this topic to Microsoft

© 2014 Microsoft