KeInitializeSemaphore

VOID
    KeInitializeSemaphore(

        IN PKSEMAPHORE  Semaphore,
        IN LONG  Count,
        IN LONG  Limit
        );

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

Parameters

Semaphore
Points 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.

Comments

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.

Callers of KeInitializeSemaphore must be running at IRQL PASSIVE_LEVEL.

See Also

KeReadStateSemaphore, KeReleaseSemaphore, KeWaitForMultipleObjects, KeWaitForSingleObject