UMS Scheduler Entry Point Function
An application’s scheduler entry point function is implemented as a
ums_scheduler_entry_point_t
function. The system calls the
application’s scheduler entry point function at the following times:
When a non-UMS thread is converted to a UMS scheduler thread by calling
enter_ums_scheduling_mode()
.When a UMS worker thread calls
ums_thread_yield()
.When a UMS worker thread terminates.
The ums_reason_t
parameter of the
ums_scheduler_entry_point_t
function specifies the reason that the
entry point function was called. If the entry point function was called because
a new UMS scheduler thread was created, the scheduler_param
parameter
contains data specified by the caller of enter_ums_scheduling_mode()
.
If the entry point function was called because a UMS worker thread yielded, the
scheduler_param
parameter contains data specified by the caller of
ums_thread_yield()
. If the entry point function was called because a
UMS worker thread terminated, the scheduler_param
parameter is NULL.
The scheduler entry point function is responsible for determining the appropriate next action for the specified thread.
When the scheduler entry point function is called, the application’s scheduler
should attempt to retrieve all of the items in its associated completion list
by calling the dequeue_ums_completion_list_items()
function. This
function retrieves a list of UMS thread contexts that have finished processing
in the kernel and are ready to run. The application’s scheduler
should not run UMS threads directly from this list because this can cause
unpredictable behavior in the application. Instead, the scheduler should
retrieve all UMS thread contexts by calling the
get_next_ums_list_item()
function once for each context, insert the
UMS thread contexts in the scheduler’s ready thread queue, and only then run
UMS threads from the ready thread queue.