OS Assignment-3: Solved Answers
------------------------------------------------------------
Question 1:
Explain Process Scheduling. Discuss different types of schedulers.
Answer:
Process Scheduling is the method by which the OS decides which process runs at a given time. It
improves CPU utilization and throughput while minimizing waiting and turnaround time.
Types of Schedulers:
1. Long-term Scheduler - Controls jobs admitted to the system.
2. Short-term Scheduler - Chooses processes from the ready queue for execution.
3. Medium-term Scheduler - Handles process swapping and suspension.
------------------------------------------------------------
Question 2:
Given processes:
| Process | Arrival | Burst |
|---------|---------|-------|
| P1 |0 |8 |
| P2 |1 |4 |
| P3 |2 |9 |
| P4 |3 |5 |
(a) FCFS Scheduling:
Order: P1 -> P2 -> P3 -> P4
Gantt: 0--8--12--21--26
Avg TAT = 15.25 ms
Avg WT = 8.75 ms
(b) SJF (Non-Preemptive):
Order: P1 -> P2 -> P4 -> P3
Gantt: 0--8--12--17--26
Avg TAT = 14.25 ms
Avg WT = 7.75 ms
------------------------------------------------------------
Question 3:
Difference between Preemptive and Non-Preemptive Scheduling
| Aspect | Preemptive | Non-Preemptive |
|----------------|---------------------|-----------------------|
| CPU Control | Taken forcefully | Till process ends |
| Responsiveness | High | Low |
| Starvation | Possible | Less likely |
| Examples | RR, SRTF | FCFS, SJF |
------------------------------------------------------------
Question 4:
Round Robin (Time Quantum = 4)
Processes:
P1: 0,10 | P2: 1,4 | P3: 2,5 | P4: 3,3
Execution Order:
P1 -> P2 -> P3 -> P4 -> P1 -> P3 -> P1
Completion Times:
P1: 22 | P2: 8 | P3: 20 | P4: 15
TAT:
P1: 22 | P2: 7 | P3: 18 | P4: 12
WT:
P1: 12 | P2: 3 | P3: 13 | P4: 9
Avg TAT = 14.75 ms
Avg WT = 9.25 ms