This service alternates active spinning and sleeping within a wait loop, until a condition is satisfied. While sleeping, a task is scheduled out and does not consume any CPU time.

rtdm_task_busy_wait() is particularly useful for waiting for a state change reading an I/O register, which usually happens shortly after the wait starts, without incurring the adverse effects of long busy waiting if it doesn't.

Parameters

[in]

condition

The C expression to be tested for detecting completion.

[in]

spin_ns

The time to spin on condition before sleeping, expressed as a count of nanoseconds.

[in]

sleep_ns

The time to sleep for before spinning again, expressed as a count of nanoseconds.

Returns

0 on success if condition is satisfied, otherwise:

-EINTR is returned if the calling task has been unblocked by a Linux signal or explicitly via rtdm_task_unblock().

-EPERM may be returned if an illegal invocation environment is detected.

Task handle as returned by rtdm_task_init(), or NULL for referring to the current RTDM task or Cobalt thread.

[in]

start_date

The initial (absolute) date of the first release point, expressed in nanoseconds. task will be delayed by the first call to rtdm_task_wait_period() until this point is reached. If start_date is zero, the first release point is set to period nanoseconds after the current date.

[in]

period

New period in nanoseconds of a cyclic task, zero to disable cyclic mode for task.

rtdm_wait_prepare() registers a wait context structure for the caller, which can be later retrieved by a call to rtdm_wait_get_context(). This call is normally issued before the current task blocks on a wait object, waiting for some (producer) code to wake it up. Arbitrary data can be exchanged between both sites via the wait context structure, which is allocated by the waiter (consumer) side.

wc is the address of an anchor object which is commonly embedded into a larger structure with arbitrary contents, which needs to be shared between the consumer (waiter) and the producer for implementing the wait code.