CPU Scheduling
Chapter 5, section 5.1, 5.2, 5.3, plus discussions on priority inversion
and priority inheritance.
- Review of Process Concepts
- Dispatcher code in the kernel
- User mode and Kernel mode:
- Definitions;
- When the CPU is in user mode, hardware prevents the execution of certain "priviledged" instructions, example: turning off the timer interrupts;
- User mode -> Kernel mode: any interrupt;
- Kernel mode -> User mode: dispatcher code, using a special instruction that jumps to the PC (program counter) of the user process and switches the mode from kernel to user;
- When is CPU scheduling done: when a process relinquishes the CPU due to being blocked or exiting, or when timer interrupts occur; sometimes, CPU scheduling is also done when a process becomes unblocked;
- Non-preemptive CPU scheduling and preemptive CPU scheduling;
- Scheduling Algorithms:
- Non-Preemptive Scheduling Algorithms: First-Come-First-Serve, Shortest-Job-First (results in minimum average waiting time);
- Preemptive Scheduling Algorithms: Round-Robin, Priority (static and dynamic), priority queues (or multi-level priorities), dynamic priority queues (or multi-level priority queues with feedbacks);
- The Priority Inversion Problem
- Solution: Priority Inheritance