ct_schedule
The ct_schedule function invokes the Cheap Threads scheduler.
Prototype:
int ct_schedule( void );
Parameters:
None.
Return Value:
CT_OKAY if successful, or CT_ERROR if not.
Discussion:
The ct_schedule function invokes the scheduler at the heart of Cheap
Threads. In turn, the scheduler invokes one or more threads, as
described in more detail elsewhere.
The scheduler continues to run until one of the following occurs:
-
A thread or user exit calls ct_halt() to
terminate the scheduler.
-
A thread or user exit calls
ct_fatal_error() to indicate an error.
-
A thread or user exit returns CT_ERROR, or any value other than
CT_OKAY.
-
The Cheap Threads software detects a fatal error internally.
-
The application is interrupted by a signal, a hardware exception, a
call to longjump(), or some other event beyond the control of the
scheduler.
Only in the first case does ct_schedule() return CT_OKAY. In the last
case it doesn't return anything. In the other cases it returns
CT_ERROR.
Restrictions:
You must define at least one active thread by calling
ct_create_thread() before calling
ct_schedule().
You may not call ct_schedule() from within a thread.
Home