Process Scheduling - TarisMajor/5143-OpSystems GitHub Wiki
Process Scheduling
Process scheduling refers to the method by which the operating system decides which process should be executed by the CPU at any given time. The scheduler ensures that all processes get a fair amount of CPU time and resources.
CPU Scheduling
CPU scheduling is a subset of process scheduling that specifically determines the order in which processes are allocated CPU time. Its goal is to maximize CPU utilization while ensuring fairness and efficiency.
Preemptive vs. Non-Preemptive Scheduling
Preemptive scheduling allows the operating system to interrupt a currently running process and allocate CPU time to another process. Non-preemptive scheduling, on the other hand, allows processes to run to completion without interruption unless they voluntarily yield control.
First-Come, First-Served (FCFS)
First-Come, First-Served (FCFS) is a simple CPU scheduling algorithm that schedules processes in the order they arrive in the ready queue, without preemption. The first process to arrive is executed first.
Shortest Job Next (SJN)
Shortest Job Next (SJN) is a CPU scheduling algorithm that selects the process with the smallest execution time from the ready queue to execute next. It minimizes average waiting time but can be challenging to implement because the exact execution time of a process is often unknown in advance.
Priority Scheduling
Priority Scheduling assigns a priority level to each process and executes the process with the highest priority first. If two processes have the same priority, other factors such as arrival time or FCFS might be used.
Round Robin (RR)
Round Robin (RR) is a preemptive CPU scheduling algorithm where each process is assigned a fixed time slice (quantum). After a process’s time slice expires, the next process is scheduled, and the process is placed back in the ready queue.
Shortest Remaining Time (SRT)
Shortest Remaining Time (SRT) is a preemptive version of Shortest Job Next (SJN) scheduling. It selects the process with the smallest remaining execution time to execute next. If a new process with a shorter remaining time arrives, it preempts the current process.
Multi-Level Queue Scheduling
Multi-Level Queue Scheduling divides processes into multiple queues based on priority or other criteria, such as process type (interactive, batch, etc.). Each queue may have its own scheduling algorithm, and processes are assigned to specific queues.
Multi-Level Feedback Queue Scheduling
Multi-Level Feedback Queue Scheduling is a more dynamic version of Multi-Level Queue Scheduling. Processes can move between different queues based on their behavior (e.g., CPU bursts). The goal is to give interactive processes higher priority and allocate CPU time efficiently.
Completely Fair Scheduler (CFS)
The Completely Fair Scheduler (CFS) is a CPU scheduling algorithm used in modern Linux systems. It aims to distribute CPU time fairly among all processes, giving each process a proportionate share of the CPU based on its weight, or priority.
Sources:
- Operating System Concepts by Abraham Silberschatz, Peter B. Galvin, and Greg Gagne
- Modern Operating Systems by Andrew S. Tanenbaum and Herbert Bos
- Introduction to Operating Systems by H.M. Deitel, Paul J. Deitel, and David R. Choffnes
- Operating Systems: Design and Implementation by Andrew S. Tanenbaum
- ChatGPT