Introduction (परिचय)
CPU Scheduling में सिर्फ process select करना ही काफी नहीं होता।
यह भी जरूरी है कि selection किस rule के आधार पर हो।
इसी rule को Scheduling Algorithm कहा जाता है।
Scheduling Algorithm क्या होता है
Scheduling Algorithm वह method है जिसके आधार पर Operating System decide करता है कि कौन सा process CPU पहले प्राप्त करेगा।
Main Scheduling Algorithms
अब हम एक-एक करके सभी important algorithms समझते हैं:
1. FCFS (First Come First Serve)
Concept
जो process पहले आता है, वही पहले execute होता है।
Working
- Processes arrival order में execute होते हैं
- Queue का concept use होता है
Example
Processes:
P1, P2, P3
Arrival order:
P1 → P2 → P3
Execution order भी वही होगा:
P1 → P2 → P3

Advantage
- Simple और easy
Disadvantage
- Waiting time ज्यादा हो सकता है
2. SJF (Shortest Job First)
Concept
जिस process का burst time सबसे कम होता है, उसे पहले execute किया जाता है।
Example
Processes:
P1 (5 sec), P2 (2 sec), P3 (3 sec)
Execution order:
P2 → P3 → P1

Advantage
- Minimum waiting time
Disadvantage
- Long processes को wait करना पड़ सकता है (starvation)
3. Priority Scheduling
Concept
हर process को एक priority दी जाती है
जिसकी priority ज्यादा होती है, वह पहले execute होता है
Example
Processes:
P1 (priority 3), P2 (priority 1), P3 (priority 2)
Execution order:
P2 → P3 → P1

Advantage
- Important tasks जल्दी complete होते हैं
Disadvantage
- Low priority process starvation
4. Round Robin (RR)
Concept
हर process को equal time (time quantum) दिया जाता है
Working
- Process को fixed time मिलता है
- Time खत्म → next process
Example
Processes:
P1, P2, P3
Time quantum = 2 sec
Execution:
P1 → P2 → P3 → फिर वापस P1

Advantage
- Fair scheduling
- No starvation
Disadvantage
- ज्यादा context switching
Simple Comparison
| Algorithm | Concept | Advantage | Problem |
|---|---|---|---|
| FCFS | First come first | Simple | High waiting |
| SJF | Shortest job first | Fast | Starvation |
| Priority | High priority first | Important work fast | Starvation |
| Round Robin | Time sharing | Fair | Overhead |
Important Exam Point
- Gantt Chart बनाना आना चाहिए
- Waiting Time और Turnaround Time निकालना आता होना चाहिए
- Numerical questions अक्सर SJF और Round Robin से आते हैं
Conclusion
Scheduling Algorithms CPU utilization को improve करते हैं और processes को efficient तरीके से execute करते हैं।
हर algorithm का अपना use-case होता है, इसलिए situation के अनुसार सही algorithm choose किया जाता है।