ct_wait
The ct_wait function suspends processing for a thread until it
receives a message.
Prototype:
int ct_wait( void );
Parameters:
None.
Return Value:
CT_OKAY if successful, or CT_ERROR if not. Currently the only way to
get an error from ct_wait() is to call it when the scheduler is not
running.
Discussion:
When a thread calls ct_wait(), the scheduler notes that the thread
is to be put to sleep, i.e. suspended to await an event. When the
scheduler regains control, it adds the thread to a list of sleeping
threads. The thread will not run again until it receives an event.
At that point the scheduler moves the thread from the sleeper queue
to the highest priority run queue.
However, if the thread returns without emptying its message queue,
the call to ct_wait() will be ignored. The scheduler will enqueue
the thread for execution at the highest priority.
Note that the waiting doesn't occur during the call to ct_wait().
Rather, the waiting starts after the thread executes a return statement
in the usual way, returning control to the scheduler.
See also the description elsewhere of the
scheduler internals.
Restrictions:
It makes sense to call ct_wait() only from a thread or user exit, i.e.
when the scheduler is running. If you call ct_wait() when the
scheduler is not running, it returns CT_ERROR, and puts the scheduler
into an error state that you can clear only by calling
ct_clear().
Home