Operating System
OS Part-1
OS Part-2
- File Concepts and Access methods
- Free Space Management and Allocation methods
- Directory Systems and Protection
- File Organization, Sharing and Implementation issues
- Disk and Drum Scheduling
- I/O Devices Organisation & I/O Buffering
- I/O Hardware, Kernel I/O subsystem and Transforming I/O Requests to Hardware Operations
- Device Drivers and Path Management
- Device Driver Sub Modules and Procedure
- Device Scheduler and Handler
- Interrupt Service Routine (ISR)
- File System in Linux and Windows
OS Part-3
- Process and Process Control Block(PCB)
- Process Scheduling( Preemptive and Non Preemptive)
- Scheduling Algorithms
- Algorithm Evaluation
- Multiple Processor Scheduling
- Real Time Scheduling
- Operations on Processes
- Threads
- Inter-Process Communication
- Precedence Graphs
- Critical Section Problem
- Semaphores
- Classical Problems of Synchronization
- DeadLock
- Deadlock Prevention and Avoidance
- Deadlock Detection and Recovery
- Process Management in Linux
OS Part-4
- Memory Hierarchy in OS
- Concepts of Memory Management
- MFT and MVT
- Logical and Physical Address Space
- Swapping
- Contiguous and Non Contiguous Memory Allocation
- Paging
- Segmentation
- Paging Combined with Segmentation
- Structure and Implementation of Page Table
- Virtual Memory in OS
- Cache Memory Organization
- Demand Paging
- Page Replacement Algorithms
- Allocation of Frames and Thrashing
- Demand Segmentation
OS Part-5
- Distributed Operating System: Introduction and Types
- Distributed OS: Design Issues
- Distributed OS: File System
- Distributed OS: Remote File Access
- Remote Procedure Call(RPC)
- Remote Method Invocation(RMI)
- Distributed Shared Memory
- Parallel Processing and Concurrent Programming
- Security and Threats Protection in Distributed OS
- Security Design Principles and Authentication in Distributed OS
- Sensor Network and Parallel OS
Scheduling Algorithms in Operating System
Introduction
Scheduling algorithm decide karta hai ki kaunsa process CPU ko kab milega. Iska goal hota hai CPU utilization badhana, response time kam karna, aur processes ko fair execution dena.
Types of Scheduling Algorithms
Scheduling algorithms do tarah ke hote hain:
-> Non-Preemptive Scheduling – Ek baar CPU kisi process ko mil gaya toh usko complete hone tak interrupt nahi kar sakte.
-> Preemptive Scheduling – Running process ko beech me rok kar dusre process ko CPU diya ja sakta hai.
1. First Come First Serve (FCFS) Scheduling
Type: Non-Preemptive
Working: Jo process pehle aayega, use CPU pehle milega.
Example:
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 5 |
P2 | 1 | 3 |
P3 | 2 | 8 |
Gantt Chart
| P1 | P2 | P3 |
0 5 8 16
Turnaround Time (TAT) = Completion Time – Arrival Time
Waiting Time (WT) = Turnaround Time – Burst Time
(Burst Time: ek process ko CPU pr continuously chalne ke liye jitna actual time chahiye hota hai)
Advantages: Simple aur easy to implement.
Disadvantages: “Convoy Effect” hota hai (bade processes, chhoti processes ko delay kar dete hain).
2. Shortest Job First (SJF) Scheduling
Type: Preemptive ya Non-Preemptive dono ho sakta hai.
Working: Jo process ka burst time sabse chhota hoga, usko pehle execute karenge.
Example (Non-Preemptive)
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 7 |
P2 | 1 | 5 |
P3 | 2 | 1 |
P4 | 3 | 2 |
Gantt Chart
| P3 | P4 | P2 | P1 |
2 4 9 16
Advantages: Average waiting time kam hoti hai.
Disadvantages: Longer processes starvation face kar sakte hain.
3. Shortest Remaining Time First (SRTF)
Type: Preemptive version of SJF.
Working: Har time unit pe, jo process ka remaining burst time sabse kam hoga, usko CPU milega.
Advantages: Turnaround time improve hota hai.
Disadvantages: Frequent context switching ki wajah se overhead badhta hai.
4. Priority Scheduling
Type: Preemptive ya Non-Preemptive dono ho sakta hai.
Working: Har process ki ek priority hoti hai, jiska priority high hoga, usko CPU milega.
Process | Arrival Time | Burst Time | Priority |
---|---|---|---|
P1 | 0 | 4 | 2 |
P2 | 1 | 3 | 1 |
P3 | 2 | 1 | 3 |
Gantt Chart
| P2 | P1 | P3 |
1 4 5 6
Advantages: Real-time systems ke liye useful.
Disadvantages: Lower priority wale processes starvation face kar sakte hain.
5. Round Robin (RR) Scheduling
Type: Preemptive
Working: Har process ko ek fixed time quantum milta hai. Agar process complete nahi hota, toh usko queue ke end me daal diya jata hai.
Example (Time Quantum = 2)
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 5 |
P2 | 1 | 3 |
P3 | 2 | 8 |
Gantt Chart
| P1 | P2 | P3 | P1 | P3 | P3 |
0 2 4 6 8 10 12
Advantages: Fair execution.
Disadvantages: Frequent context switching se overhead badh jata hai.
6. Multilevel Queue Scheduling
Type: Preemptive ya Non-Preemptive dono ho sakta hai.
Working: Processes ko different queues me divide kiya jata hai (jaise ki foreground, background). Har queue ka apna scheduling algorithm hota hai.
Advantages: System aur user processes ko alag treat kar sakte hain.
Disadvantages: Queue priorities manage karna difficult hota hai.
Comparison of Scheduling Algorithms
Algorithm | Preemptive | Non-Preemptive | Best For |
---|---|---|---|
FCFS | No | Yes | Simple workloads |
SJF | No | Yes | Batch systems |
SRTF | Yes | No | Fast turnaround |
Priority | Yes/No | Yes/No | Real-time systems |
Round Robin | Yes | No | Time-sharing OS |
Multilevel Queue | Yes/No | Yes/No | Multi-user environments |
Conclusion
Har scheduling algorithm ka apna advantage aur disadvantage hota hai. Round Robin multitasking ke liye best hai, jabki SJF aur Priority Scheduling fast turnaround provide karte hain. Kis algorithm ko use karna hai, yeh system ki requirement pe depend karta hai.