RtkWaitForMultipleObjects
RtkWaitForMultipleObjects allows a thread to wait on one of multiple objects to be signaled.
Syntax
NTSTATUS RtkWaitForMultipleObjects(
[in] RTSSINST RtssInst,
[in] ULONG Count,
[in] CONST HANDLE *Handles,
[ignored] BOOLEAN WaitAll,
[in] ULONG Milliseconds
);
Parameters
[in] RtssInst
An RTSSINST value returned from a call to RtkRtssAttach or RtkRtssAttachEx. Pass a valid RTSSINST value or the call will fail with STATUS_INVALID_PARAMETER.
[in] Count
Specifies the number of object handles in the array pointed by Handles. The maximum number of object handles is MAX_WFMO, defined in RtkApi.h.
[in] Handles
An array of handles to open object handles. See the list of the object types whose handles can be specified in the Remarks section. If one of these handles is closed while the wait is still pending, the function’s behavior is undefined.
[ignored] WaitAll
Ignored. Specifies the wait type. This is always FALSE, the function returns when the state of any one of the objects is set to signaled. The return value indicates the object whose state caused the function to return.
[in] Milliseconds
The time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is non-signaled. If Milliseconds is zero, the function tests the object's state and returns immediately. If Milliseconds is INFINITE, the function's time-out interval never elapses.
Return Value
If the function succeeds, it returns STATUS_SUCCESS. If the function fails, it returns a different value.
Possible return values:
| Return value | Meaning |
|---|---|
|
STATUS_WAIT_0 to (STATUS_WAIT_0 + Count - 1) |
The return value minus STATUS_WAIT_0 indicates the Handles array index of the object that satisfied the wait. If more than one object became signaled during the call, this is the array index of the signaled object with the smallest index value of all the signaled objects. |
|
STATUS_ABANDONED_WAIT_0 to (STATUS_ABANDONED_WAIT_0 + Count - 1) |
The return value minus STATUS_ABANDONED_WAIT_0 indicates the Handles array index of an abandoned mutex object that satisfied the wait. |
|
STATUS_TIMEOUT |
The time-out interval elapsed, and the conditions specified by the WaitAll parameter are not satisfied. |
|
STATUS_UNSUCCESSFUL |
The function failed to wait. |
|
STATUS_INVALIDPARAMETER |
The functions failed with an invalid parameter. |
Remarks
RtkWaitForMultipleObjects determines whether the wait criteria have been met. If they have not, the calling thread enters the wait state. It uses no processor time while waiting for them to be met.
The function returns when one of these events occurs:
- Any one of the specified objects is in the signaled state
- The time-out interval elapses
The function modifies the state of some synchronization objects. Modification occurs only for the object or objects whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one.
RtkWaitForMultipleObjects can specify handles of any of the following object types in the Handles array:
- Event – The RtkCreateEvent or RtkOpenEvent function returns the handle. The RtkSetEvent or RtkPulseEvent function explicitly sets an event object's state to signaled. The RtkResetEvent function must explicitly reset a manual-reset event object's state to non-signaled. For an auto-reset event object, the wait function resets the object's state to non-signaled before returning.
- Mutex – RtkCreateMutex and RtkOpenMutex return handles to the mutex object, which becomes signaled when it is unowned.
- Semaphore – RtkCreateSemaphore or RtkOpenSemaphore returns the handle. A semaphore object maintains a count between zero and some maximum value. Its state is signaled when its count exceeds zero and non-signaled when its count is zero. If the current state is signaled, the wait function decreases the count by one.
Requirements
| Minimum supported version | Header | Library |
IRQL |
|---|---|---|---|
|
wRTOS 1.0 SDK |
RtkApi.h |
RtkApi_W64.lib |
PASSIVE_LEVEL |
See Also: