Table of contents
- CPU Process Scheduling Algorithms
- Timings in CPU Scheduling
- First Come First Serve(FCFS) CPU Scheduling Algorithm
- Shortest Job First(SJF) CPU Scheduling Algorithm
- Shortest Job First with Preemption(SJF + Preemption) CPU Scheduling Algorithm
- Round Robin(RR) CPU Scheduling Algorithm
- Pre-Emptive Priority CPU Scheduling Algorithm
- Multilevel Queue Scheduling
- Multilevel Feedback Queue Scheduling
- Conclusion
CPU Process Scheduling Algorithms
Two types - Preemptive & Non-Preemptive
Pre-Emptive Algorithms | Non Pre-Emptive Algorithms |
1. SRTF(Shortest Remaining Time First) | 1. FCFS(First Come First Serve) |
2. LRTF(Longest Remaining Time First) | 2. SJF(Shortest Job First) |
3. Round Robin | 3. LJF(Longest Job First) |
4. Priority based | 4. HRRN(Highest Response Ratio Next) |
5. Multilevel Queue |
Timings in CPU Scheduling
- Arrival Time - The time at which process enters the Ready queue or State.
- Burst Time - Time required by a process to get executed on CPU.
- Completion Time - The time at which process completes its execution.
- Turn Around Time = { Completion Time - Arrival Time }
- Waiting Time = { Turn Around Time - Burst Time }
- Response Time = { Time at which a process gets CPU first time - Arrival Time }
First Come First Serve(FCFS) CPU Scheduling Algorithm
- Criteria : Arrival Time.
- Mode : Non-Preemptive.
- Use Gantt Chart to solve numericals.
- Based on given Arrival and Burst Times of various processes, we find out their completion time, turnaround time, waiting time, response time using their formulas.
- Also, find the average completion time, average turnaround time and average waiting time.
- Response time will be equal to waiting time because FCFS is non-preemptive.
Shortest Job First(SJF) CPU Scheduling Algorithm
- Criteria : Processes with least Burst Time.
- Mode : Non - Preemptive.
- Similar to FCFS, based on given arrival and burst times, we find out their completion time, turnaround time, waiting time, and response time.
- Plot the Gantt Chart for processes being executed in CPU.
- Calculate the average timings.
- In non-preemptive algorithms, waiting time is always equal to response time.
Shortest Job First with Preemption(SJF + Preemption) CPU Scheduling Algorithm
- SJF with Preemption is also known as Shortest Remaining Time First(SRTF) Scheduling Algorithm.
- Criteria : Burst Time.
- Mode : Preemptive.
- More complicated numericals as you have to check the least burst time among all processes in the ready queue at every step.
- If two processes have equal burst time, then consider their arrival times. The process with lower arrival time gets executed first.
- Response time will be different than waiting time, because of preemption.
Round Robin(RR) CPU Scheduling Algorithm
- Criteria : Time Quantum
- Mode : Preemptive
- Use two Gantt charts for Ready Queue and Running Queue. Based on the given Time Quantum value, the arrival and burst times of processes, we calculate the CT, TAT, WT, RT.
- Context switching happens when a running process is preempted back into the Ready Queue from the Running Queue when it has run for the specified Time Quantum value. The context of the Process Control Block of the running process is saved and the process is sent back to the Ready Queue and a new process is brought in to be executed.
Pre-Emptive Priority CPU Scheduling Algorithm
- Criteria : Priority.
- Mode : Pre-Emptive.
- Wether Higher Number = Higher Priority OR Lower Number = Higher Priority. Will be given in the question.
- Based on the priority of processes, arrival and burst times, we calculate the CT, TAT, WT. Use Gantt chart for Running Queue.
- In case of equal priority of two processes, use their arrival time. The one with lower arrival time gets executed first.
Multilevel Queue Scheduling
- Processes can be of different types, and there are different Ready Queues for them.
- System Processes have highest priority and are scheduled using Round Robin algorithm.
- Interactive Processes like media players have medium priority scheduled using SJF algorithm and have a separate Ready queue.
- Batch Processes are background processes, have lowest priority scheduled using FCFS algorithm.
- Drawback is that the response times of batch processes will be very high, because the system processes will keep the CPU occupied leaving less time for interactive and batch processes to execute. This is the problem of starvation. This drawback is overcome by Multilevel Feedback Queue Scheduling.
Multilevel Feedback Queue Scheduling
- Lowest priority processes face the problem of starvation, which can be solved by feedback, where a low priority processes is progressively upgraded to a higher priority queue each time it is executed for a defined time quantum.
- Processes which are already high priority do not face the problem of starvation.
- The lowest priority process is executed for some time quantum, or it can be any algorithm for that matter. It is then given an upgrade to a queue having a higher priority and this process continues to the highest priority queue till the process has been executed completely.
Conclusion
You can read other articles written by me through these links.
Operating System Series
1. Introduction & Types of OS
2. Process States & Lifecycle
3. System Calls
4. User Mode vs Kernel Mode
5. CPU Process Scheduling
6. Process Synchronization
7. Deadlocks
8. Memory Management
9. Disk Management & Scheduling
10. File System in OS
11. Protection & Security
System Design Series
Introduction To Parallel Computing
Deep Dive Into Virtualization
Insights Into Distributed Computing
Cloud Computing Series
1. Cloud Service Models
2. Cloud Deployment Models
3. Cloud Security
4. Cloud Architecture
5. Cloud Storage
6. Networking In The Cloud
7. Cloud Cost Management
8. DevOps In Cloud & CI/CD
9. Serverless Computing
10. Container Orchestration
11. Cloud Migration
12. Cloud Monitoring & Management
13. Edge Computing In Cloud
14. Machine Learning In Cloud
Computer Networking Series
1. Computer Networking Fundamentals
2. OSI Model
3. TCP/IP Model : Application Layer
4. TCP/IP Model : Transport Layer
5. TCP/IP Model : Network Layer
6. TCP/IP Model : Data Link Layer
Version Control Series
1. Complete Guide to Git Commands
2. Create & Merge Pull Requests
3. Making Open Source Contributions
Linux
Complete Guide to Linux Commands
Thanks For Reading! ๐
Garvit Singh