Skip to content

WaitOn

Waits until h has something to report, or timeout milliseconds pass.

Number Selector Blocking Since
0x07 SVC_WAITON — yes 2.0
SvcResult WaitOn(Handle h, Duration timeout);

Registers: (h, timeout) -> r0 status, r1-r3 per handle type

The generic wait for ports, events, tasks and spaces; it returns as soon as something arrives. What r1-r3 carry depends on the type of h:

Handle

r1

r2

r3

Port

sender's marker

message length

granted handle, or -1

Event

signalled bits (now cleared)

Task

exit status or fault reason

TASK_EXITED or TASK_FAULTED

Space

last task's exit status

Receiving on a port leaves the caller holding the call: it must Reply() or Hold() before receiving again. Waiting on a task that has already exited or faulted returns at once with ZUZU_OK. WaitOnPort(), WaitOnEvent(), WaitOnTask() and WaitOnSpace() unpack the result into typed structs.

Parameters

Name Direction Description
h in Port, event, task or space handle with PERM_WAIT.
timeout in Milliseconds to wait; TIMEOUT_POLL checks and returns at once, TIMEOUT_INFINITE waits forever.

Returns

r0 is the status; r1-r3 as in the table above.

Errors

Error Condition
ERR_TIMEOUT Nothing arrived within timeout (or nothing was there, for a poll).
ERR_BADHANDLE h is not a live handle.
ERR_NOPERM h lacks PERM_WAIT.
ERR_BADTYPE h is not a port, event, task or space.
ERR_DEAD The port or event was destroyed, or the space was torn down.
ERR_BUSY Port only: the caller still holds an unanswered call.
ERR_BADARG h is the caller's own task or own space.