Evaluate Round Robin CPU Scheduling algorithm for given Problem Time slice =3 ms.
Process | P1 | P2 | P3 | P4 |
Process Time | 10 | 5 | 18 | 6 |
Arrival Time | 5 | 3 | 0 | 4 |
Given:
- Time Slice (Quantum): 3 ms
- Processes:
- P1: Burst Time = 10 ms, Arrival Time = 5 ms
- P2: Burst Time = 5 ms, Arrival Time = 3 ms
- P3: Burst Time = 18 ms, Arrival Time = 0 ms
- P4: Burst Time = 6 ms, Arrival Time = 4 ms
Step 1: Order of Execution
We will simulate the round-robin scheduling process:
Process Arrival:
- P3 arrives at time 0 ms. Burst Time = 18 ms
- P2 arrives at time 3 ms. Burst Time = 5 ms
- P4 arrives at time 4 ms. Burst Time = 6 ms
- P1 arrives at time 5 ms. Burst Time = 10 ms
Time Chart: We will execute each process for up to 3 ms (time slice) in a round-robin manner, continuing until all processes are completed.
Time (ms) Process Executed Remaining Time of Process 0 - 3 P3 P3 (15 ms left) 3 - 6 P2 P2 (2 ms left) 6 - 9 P4 P4 (3 ms left) 9 - 12 P1 P1 (7 ms left) 12 - 15 P3 P3 (12 ms left) 15 - 17 P2 P2 (0 ms, completed) 17 - 20 P4 P4 (0 ms, completed) 20 - 23 P1 P1 (4 ms left) 23 - 26 P3 P3 (9 ms left) 26 - 29 P1 P1 (1 ms left) 29 - 32 P3 P3 (6 ms left) 32 - 33 P1 P1 (0 ms, completed) 33 - 36 P3 P3 (3 ms left) 36 - 39 P3 P3 (0 ms, completed)
Step 2: Calculate Completion Time, Turnaround Time, and Waiting Time
Completion Time (CT): The time at which each process completes execution.
Turnaround Time (TAT): The total time taken from arrival to completion of a process.
Waiting Time (WT): The total time the process spends waiting in the ready queue.
Process | Arrival Time (AT) | Burst Time (BT) | Completion Time (CT) | Turnaround Time (TAT) | Waiting Time (WT) |
---|---|---|---|---|---|
P1 | 5 ms | 10 ms | 33 ms | 28 ms | 18 ms |
P2 | 3 ms | 5 ms | 17 ms | 14 ms | 9 ms |
P3 | 0 ms | 18 ms | 39 ms | 39 ms | 21 ms |
P4 | 4 ms | 6 ms | 20 ms | 16 ms | 10 ms |
Step 3: Summary of Metrics
Step 3: Summary of Metrics
- Average Turnaround Time (TAT):
- Average Waiting Time (WT):
- Completion Order: P2, P4, P1, P3
- Average Turnaround Time: 24.25 ms
- Average Waiting Time: 14.5 ms
Given:
- Processes:
- P1: Burst Time = 5 ms, Arrival Time = 0 ms
- P2: Burst Time = 7 ms, Arrival Time = 1 ms
- P3: Burst Time = 4 ms, Arrival Time = 3 ms
- Time Quantum: 2 ms
Step 1: Gantt Chart
Initial State:
- P1 arrives at 0 ms.
- P2 arrives at 1 ms.
- P3 arrives at 3 ms.
Execution Sequence:
- Time 0 - 2: P1 executes (Remaining Burst Time: P1 = 3 ms).
- Time 2 - 4: P2 executes (Remaining Burst Time: P2 = 5 ms).
- Time 4 - 6: P3 executes (Remaining Burst Time: P3 = 2 ms).
- Time 6 - 8: P1 executes (Remaining Burst Time: P1 = 1 ms).
- Time 8 - 10: P2 executes (Remaining Burst Time: P2 = 3 ms).
- Time 10 - 12: P3 executes (Remaining Burst Time: P3 = 0 ms, completed).
- Time 12 - 14: P1 executes (Remaining Burst Time: P1 = 0 ms, completed).
- Time 14 - 16: P2 executes (Remaining Burst Time: P2 = 1 ms).
- Time 16 - 17: P2 completes (Remaining Burst Time: P2 = 0 ms).
Gantt Chart:
Step 2: Completion Time (CT), Turnaround Time (TAT), and Waiting Time (WT)
Completion Time (CT): The time at which each process completes its execution.
Turnaround Time (TAT): The total time taken from arrival to completion.
Waiting Time (WT): The total time a process spends waiting in the ready queue.
Process | Arrival Time (AT) | Burst Time (BT) | Completion Time (CT) | Turnaround Time (TAT) | Waiting Time (WT) |
---|---|---|---|---|---|
P1 | 0 ms | 5 ms | 14 ms | 14 ms | 9 ms |
P2 | 1 ms | 7 ms | 17 ms | 16 ms | 9 ms |
P3 | 3 ms | 4 ms | 12 ms | 9 ms | 5 ms |
Step 3: Average Waiting Time
- Average Waiting Time (WT):
Completion Time (CT): P1 = 14 ms, P2 = 17 ms, P3 = 12 ms
Average Turnaround Time (TAT): 13 ms
Average Waiting Time (WT): 7.67 ms
No comments:
Post a Comment