KeInitializeSemaphore function (wdm.h)

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

Syntax

void KeInitializeSemaphore(
  [out] PRKSEMAPHORE Semaphore,
  [in]  LONG         Count,
  [in]  LONG         Limit
);

Parameters

[out] Semaphore

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

[in] 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.

[in] 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

Requirement Value
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 HwStorPortProhibitedDDIs(storport), IrqlKeDispatchLte(wdm), PowerIrpDDis(wdm)

See also

KeReadStateSemaphore

KeReleaseSemaphore

KeWaitForMultipleObjects

KeWaitForSingleObject