KeInitializeSemaphore function

The KeInitializeSemaphore routine initializes a semaphore object with a specified count and specifies an upper limit that the count can attain.

Syntax

void KeInitializeSemaphore(
  PRKSEMAPHORE Semaphore,
  LONG         Count,
  LONG         Limit
);

Parameters

Semaphore

Pointer to a dispatcher object of type semaphore, for which the caller provides the storage.

Count

Specifies the initial count value to be assigned to the semaphore. This value must be positive. A nonzero value sets the initial state of the semaphore to signaled.

Limit

Specifies the maximum count value that the semaphore can attain. This value must be positive. It determines how many waiting threads become eligible for execution when the semaphore is set to the signaled state and can therefore access the resource that the semaphore protects.

Return Value

None

Remarks

The semaphore object is initialized with the specified initial count and limit.

Storage for a semaphore object must be resident: in the device extension of a driver-created device object, in the controller extension of a driver-created controller object, or in nonpaged pool allocated by the caller.

For more information about semaphore objects, see Semaphore Objects.

Requirements

   
Minimum supported client Available starting with Windows 2000.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL PASSIVE_LEVEL
DDI compliance rules IrqlKeDispatchLte, PowerIrpDDis, HwStorPortProhibitedDDIs

See Also

KeReadStateSemaphore

KeReleaseSemaphore

KeWaitForMultipleObjects

KeWaitForSingleObject