Multi-tasking
-
A logical extension of Multi-programming
-
Ability of computer executing multiple tasks at the same time by giving each Process (进程) a very small slice of CPU time
-
Focus on improving user experience
Time-Sharing
- A Implementation of Concurrency (并发)
- A specific implementation of Multi-tasking when resources are shared by multiple users at the same time, achieved with quick Context Switch
- All Time-sharing systems are Multi-programming systems
- Allow multiple remote users to run jobs on the same computer at the same time
Corporative Multitasking
- Rather than OS decides when to preempt Process (进程). Process gives up CPU and let other Process to run
CPU Hogging
Process can hog to CPU forever, modern OS adapts Preemptive Multitasking
Preemptive Multitasking
- Ensure no Process (进程) can hog the CPU forever
Mechanism
- Before jumping to program code, the OS sets the Timer Chip to trigger an Hardware interrupts (外中断) after some period of time
- The OS switches to User Mode and jumps to the next Instruction of the program
- When the Timer Chips elapses, it triggers a Hardware interrupts (外中断) to switch to Kernel Mode and jump to OS code
- The OS can now save where the program left off, load a different program, and repeat the process