Exercises on Process Scheduling with Solutions
## Exercise 1: First-Come, First-Served (FCFS) Scheduling
Given Data:
| Process | Arrival Time | Burst Time |
|---------|--------------|------------|
| P1 |0 |5 |
| P2 |1 |3 |
| P3 |2 |8 |
| P4 |3 |6 |
| P5 |4 |4 |
Solution:
1. Calculate the Completion Time (CT) for each process.
2. Turnaround Time (TAT) = CT - Arrival Time
3. Waiting Time (WT) = TAT - Burst Time
4. Compute the Average Turnaround Time and Average Waiting Time.
---
## Exercise 2: Shortest Job First (SJF) - Non-Preemptive
Given Data:
| Process | Arrival Time | Burst Time |
|---------|--------------|------------|
| P1 |0 |7 |
| P2 |2 |4 |
| P3 |4 |1 |
| P4 |5 |4 |
| P5 |6 |2 |
Solution:
1. Select the process with the shortest burst time that has arrived.
2. Compute Completion Time, Turnaround Time, and Waiting Time.
3. Compute the averages.
---
## Exercise 3: Round Robin Scheduling (Quantum = 3 units)
Given Data:
| Process | Arrival Time | Burst Time |
|---------|--------------|------------|
| P1 |0 | 10 |
| P2 |1 |4 |
| P3 |2 |5 |
| P4 |3 |6 |
| P5 |4 |7 |
Solution:
1. Allocate CPU to each process for 3 units at a time in a cyclic order.
2. Compute Completion Time, Turnaround Time, and Waiting Time.
3. Compute the averages.
---
## Exercise 4: Priority Scheduling (Non-Preemptive)
Given Data:
| Process | Arrival Time | Burst Time | Priority |
|---------|--------------|------------|----------|
| P1 |0 |6 |2 |
| P2 |1 |8 |1 |
| P3 |2 |7 |3 |
| P4 |3 |3 |2 |
| P5 |4 |4 |1 |
Solution:
1. Schedule processes based on priority (lower number = higher priority).
2. Compute Completion Time, Turnaround Time, and Waiting Time.
3. Compute the averages.
---
## Exercise 5: Shortest Remaining Time First (SRTF) - Preemptive SJF
Given Data:
| Process | Arrival Time | Burst Time |
|---------|--------------|------------|
| P1 |0 |8 |
| P2 |1 |4 |
| P3 |2 |9 |
| P4 |3 |5 |
| P5 |4 |2 |
Solution:
1. At every time unit, schedule the process with the shortest remaining time.
2. Compute Completion Time, Turnaround Time, and Waiting Time.
3. Compute the averages.