L 6.11:   thread_switch

(Revision 1 - 4 November 2000)

 

overview    system call #4
invoking thread releases processor to a designated thread with a time-slice donation or with a null argumente yields processor to any thread

parameter    designated thread tid or nil

on entry     a0  designated thread id
	     t8  pointer to caller's tcb
0 t1 ¬ caller tcb base address
1-3 TOS <-- calling thread's restart address
4,5 ready list <-- caller
6,14 if caller did not designate  a thread, use to_next_thread macro to call get_next_thread (the scheduler) to select a thread and then to switch to the selected thread with thread_switch_fast macro followed by a jump to the routine
7-9, 11-13 else if caller did designate a thread, and if it's ready, switch contexts to it using thread_switch_fast and invoke its restart routine
10,14 else if designated thread is not ready, use to_next_thread macro to call get_next_thread (the scheduler) to select a thread and then to switch to the selected thread with thread_switch_fast macro followed by a jump to the routine