Evaluate SJF CPU Scheduling algorithm for given Problem , Find Average Turn Around Time and Average Response Time
Process | P1 | P2 | P3 | P4 |
Process Time | 8 | 4 | 9 | 5 |
Arrival Time | 0 | 1 | 2 | 3 |
Given:
- Processes:
- P1: Burst Time = 8 ms, Arrival Time = 0 ms
- P2: Burst Time = 4 ms, Arrival Time = 1 ms
- P3: Burst Time = 9 ms, Arrival Time = 2 ms
- P4: Burst Time = 5 ms, Arrival Time = 3 ms
Step 1: Process Execution Order
The SJF algorithm selects the process with the shortest burst time that has arrived and is ready to execute. If two processes have the same burst time, the one that arrived earlier is selected.
Order of Execution:
- P1 arrives at 0 ms, and it starts execution immediately since it's the only process available.
- P2 arrives at 1 ms and has the shortest burst time after P1 finishes.
- P4 arrives at 3 ms and has the shortest burst time after P2 finishes.
- P3 arrives at 2 ms but has the longest burst time, so it is executed last.
Step 2: Completion Time (CT), Turnaround Time (TAT), and Response Time (RT)
- Completion Time (CT): The time at which each process completes its execution.
- Turnaround Time (TAT): The total time taken from arrival to completion of a process.
- Response Time (RT): The time from the arrival of the process until it starts executing.
Execution and Calculations
Process | Arrival Time (AT) | Burst Time (BT) | Start Time (ST) | Completion Time (CT) | Turnaround Time (TAT) | Response Time (RT) |
---|---|---|---|---|---|---|
P1 | 0 ms | 8 ms | 0 ms | 8 ms | 8 ms | 0 ms |
P2 | 1 ms | 4 ms | 8 ms | 12 ms | 11 ms | 7 ms |
P4 | 3 ms | 5 ms | 12 ms | 17 ms | 14 ms | 9 ms |
P3 | 2 ms | 9 ms | 17 ms | 26 ms | 24 ms | 15 ms |
Step 3: Average Turnaround Time and Average Response Time
Average Turnaround Time (TAT):
Average Response Time (RT):
- Order of Execution: P1, P2, P4, P3
- Average Turnaround Time: 14.25 ms
- Average Response Time: 7.75 ms
No comments:
Post a Comment