Process Scheduling
Processes cannot move themselves.
You know there are thousands of processes concurrently running on a computer sharing the CPU. You also know that they move between the CPU and the main (and secondary) memory back and forth until they exit. Do processes intelligently move inside of your computer by themselves? No, they depend on schedulers that control when and where each process should move, just like a traffic control officer does.
There are two kinds of schedulers in the picture above: high-level scheduler and low-level scheduler. The high-level scheduler enters processes into the ready queue. The ready queue is a priority queue that holds multiple processes. Another kind of scheduler, a low-level scheduler, picks a process from the ready queue and extracts it into the CPU registers. A process can typically stay in the CPU for 10 to 100ms. This time span is called a time slice. If a process finishes while running in the CPU, it exits. If a process exhausts the given time slice, the low-level scheduler moves it back in the ready queue to make room for another process to run. If a process needs an IO operation, the low-level scheduler moves it out of the CPU to the blocked queue. Processes in the blocked queue will be moved by the low-level scheduler into the ready queue once the IO operation finishes. The operation in which a process takes over the CPU owned by another process is called context switching. Context switching typically takes 10μs, which is relatively much shorter than a time slice.