[−][src]Function sunrise_kernel::scheduler::schedule
pub fn schedule()
Performs a process switch.
Queue politics
checking if thread is unlocked
and suitable for running
CURRENT_THREAD ===============================>
j--------j j--------j j--------j j--------j
| current| | X | | | | |
j--------j j--------j j--------j j--------j A
| A locked, | |
| | skipped | |
| +-----------------------------+ |
+----------------------------------------------------+
- Tries to lock the next first process. If it fails to acquire its lock, it is ignored for now, and we move on to the next one.
- When a candidate is found, it is removed from the queue, and set as CURRENT_THREAD.
- Pushes the previous current thread at the end of the queue.
- Disables interrupts
- Performs the process switch
-
- as new process * Re-enables interrupts