src/ppe/pk/kernel/pk_thread_core.c
// Schedule and run the highest-priority mapped runnable thread.
//
// The priority of the next thread to run is first computed.  This may be
// PK_THREADS, indicating that the only thread to run is the idle thread.
// This will always cause (or defer) a 'context switch' to the idle thread.
// Otherwise, if the new thread is not equal to the current thread this will
// also cause (or defer) a context switch. Note that scheduling is defined in
// terms of priorities but actually implemented in terms of PkThread pointers.
//
// If we are not yet in thread mode we're done - threads will be started by
// pk_start_threads() later. If we're in thread context a context switch
// happens immediately. In an interrupt context the switch is deferred to the
// end of interrupt processing.
Schedule and run the highest-priority mapped runnable thread.
The priority of the next thread to run is first computed.  This may be
PK_THREADS, indicating that the only thread to run is the idle thread.
This will always cause (or defer) a 'context switch' to the idle thread.
Otherwise, if the new thread is not equal to the current thread this will
also cause (or defer) a context switch. Note that scheduling is defined in
terms of priorities but actually implemented in terms of PkThread pointers.

If we are not yet in thread mode we're done - threads will be started by
pk_start_threads() later. If we're in thread context a context switch
happens immediately. In an interrupt context the switch is deferred to the
end of interrupt processing.
Schedule and run the highest - priority mapped runnable thread . The priority of the next thread to run is first computed . This may be PK_THREADS indicating that the only thread to run is the idle thread . This will always cause ( or defer ) a ' context switch ' to the idle thread . Otherwise if the new thread is not equal to the current thread this will also cause ( or defer ) a context switch . Note that scheduling is defined in terms of priorities but actually implemented in terms of PkThread pointers . If we are not yet in thread mode we ' re done - threads will be started by pk_start_threads () later . If we ' re in thread context a context switch happens immediately . In an interrupt context the switch is deferred to the end of interrupt processing .
void
__pk_schedule(void)
{
    __pk_next_priority = __pk_thread_queue_min(&__pk_run_queue);
    __pk_next_thread = __pk_priority_map[__pk_next_priority];
    if ((__pk_next_thread == 0) ||
        (__pk_next_thread != __pk_current_thread)) {
        if (__pk_kernel_mode_thread()) {
            if (__pk_kernel_context_thread()) {
                if (__pk_current_thread != 0) {
                    __pk_switch();
                } else {
                    __pk_next_thread_resume();
                }
            } else {
                __pk_delayed_switch = 1;
            }
        }
    }
}
void __pk_schedule ( void ) { __pk_next_priority = __pk_thread_queue_min ( & __pk_run_queue ) ; __pk_next_thread = __pk_priority_map [ __pk_next_priority ] ; if ( ( __pk_next_thread == 0 ) || ( __pk_next_thread != __pk_current_thread ) ) { if ( __pk_kernel_mode_thread ( ) ) { if ( __pk_kernel_context_thread ( ) ) { if ( __pk_current_thread != 0 ) { __pk_switch ( ) ; } else { __pk_next_thread_resume ( ) ; } } else { __pk_delayed_switch = 1 ; } } } }
Schedule and run the highest-priority mapped runnable thread.
Schedule and run the highest - priority mapped runnable thread .