Export (0) Print
Expand All
Expand Minimize

KeEnterCriticalRegion routine

The KeEnterCriticalRegion routine temporarily disables the execution of normal kernel APCs, but does not prevent special kernel APCs from running.

Syntax


VOID KeEnterCriticalRegion(void);

Parameters

This routine has no parameters.

Return value

None

Remarks

A driver calls this routine to enter a critical region in which the execution of normal kernel APCs is deferred until this driver exits the critical region by calling the KeLeaveCriticalRegion routine. Any caller of KeEnterCriticalRegion should call KeLeaveCriticalRegion as quickly as possible after entering a critical region.

Highest-level drivers can call KeEnterCriticalRegion while running in the context of the thread that requested the current I/O operation.

A thread that is inside a critical region has both user APCs and normal kernel APCs disabled, but not special kernel APCs. For more information about these APC types, see Types of APCs.

Critical regions can be entered recursively and each call to KeEnterCriticalRegion must have a matching call to KeLeaveCriticalRegion.

A driver can use a critical region to acquire and release exclusive access to a shared resource. In this case, the ExEnterCriticalRegionAndAcquireResourceExclusive and ExReleaseResourceAndLeaveCriticalRegion routines can be used instead of the KeEnterCriticalRegion and KeLeaveCriticalRegion routines. For more information, see the code example in ExEnterCriticalRegionAndAcquireResourceExclusive.

For more information about APCs, see Asynchronous Procedure Calls.

Requirements

Version

Available starting with Windows 2000.

Header

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

Library

Ntoskrnl.lib

IRQL

<= APC_LEVEL

DDI compliance rules

CriticalRegions, IrqlKeApcLte2, WithinCriticalRegion, HwStorPortProhibitedDDIs, WithinCriticalRegion(storport)

See also

ExEnterCriticalRegionAndAcquireResourceExclusive
ExReleaseResourceAndLeaveCriticalRegion
KeAreApcsDisabled
KeLeaveCriticalRegion

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft