Abstract


Purpose

Focus on improving user experience.

Corporative Multitasking


CPU Hogging

Process can hog to CPU forever, modern OS adapts Preemptive Multitasking instead.

Preemptive Multitasking


  1. Before jumping to program code, the Kernel sets the Timer Chip to trigger an Hardware interrupts (外中断) after some period of time
  2. The kernel switches to User Mode and jumps to the next Instruction of the program
  3. When the Timer Chips elapses, it triggers a Hardware interrupts. The CPU receives the interrupt.
  4. The hardware interrupt stores Program Counter, so it can resume later
  5. The hardware interrupt invokes corresponding Interrupt Handler
  6. Interrupt passes control to Process Scheduler selects a process to run by restoring the state of the CPU for that process from the process’s PCB
  7. Repeat step 1 to step 7

No CPU Hogging

Ensure no Process (进程) can hog the CPU forever.