BOOL osWaitForObjects( HANDLE *Handles, INDEX Count, TIME Timeout, INDEX *ObjectIndex );
A pointer to an array of object handles.
The number of handles in the array.
The time-out interval for the wait operation.
A pointer to a variable that receives the index of the object that caused the function to return (may be NULL if this information is not required).
Returns TRUE on success or FALSE on failure. Call the osGetLastError function to obtain extended error information.
This function suspends task execution until at least one of the specified objects enters the signaled state or the timeout interval elapses.
A system object can be in one of two states: signaled or non-signaled. A task may wait for one or more objects to check their state. When a task calls a system wait function on a non-signaled object, its execution is suspended until the object changes its state to signaled. When a task waits for multiple objects, it is released if at least one of the objects enters the signaled state. If multiple tasks are waiting for the same object, they are queued according to their priority. If a task performs a wait operation on an already signaled object, it continues execution, and the wait function returns success immediately.
A task is released only when two conditions are met: the object is signaled and the task is eligible to run (i.e., no higher-priority tasks are currently being processed). If a higher-priority task is executing when the object changes to the signaled state, the waiting task will only start once all higher-priority tasks become blocked (see scheduling). If the object reverts to a non-signaled state before the task can be started, the wait function will not return until both conditions are fulfilled again.
To wait for a single object, use the osWaitForObject function. To wait for multiple objects, use the osWaitForObjects function. This is available only when the maximum number of objects a task can wait for is greater than one. Use the OS_MAX_WAIT_FOR_OBJECTS constant to define the maximum number of objects for which a task can wait.
Wait functions allow passing a timeout parameter, which defines the maximum duration a task waits for an object. When set to 0 (or OS_IGNORE), the task merely checks the object state and returns immediately. If the object is signaled, it returns success; otherwise, it fails and sets the last error code to ERR_WAIT_TIMEOUT. Specifying OS_INFINITE as a timeout causes the task to wait indefinitely until the object becomes signaled. Any other value specifies a timeout in system time units. Values other than 0, OS_IGNORE, and OS_INFINITE may be specified only when OS_USE_WAITING_WITH_TIME_OUT is set to 1. The task will wait until an object state changes to signaled or the specified timeout elapses. For more information on time units, refer to the time and timeouts section under synchronization.
For more information, please refer to the synchronization section.
| Version: | 1.0 |
|---|---|
| Header file: | OS_API.h |
| See also: | AR_TIME_IGNORE, AR_TIME_INFINITE, BOOL, FALSE, NULL, OS_MAX_WAIT_FOR_OBJECTS, osGetLastError, osWaitForObject, scheduling, synchronization, TIME, TRUE |