Sub topic 11
Scheduling Criteria: Turnaround, Waiting, and Response Time
Prerequisites and the Three Measurements
Assume you know process arrival time, CPU burst time, and basic scheduling queues. A CPU burst is the amount of CPU time a process needs. An arrival time is when the process enters the ready queue.
Scheduling questions usually use these times:
- Completion time (CT): when the process finishes.
- Turnaround time (TAT): total time from arrival to completion.
- Waiting time (WT): time spent waiting in the ready queue.
- Response time (RT): time from arrival until the process first gets the CPU.
For a process with arrival time AT, burst time BT, and first start time ST:
| Criterion | Formula | Meaning |
|---|---|---|
| Turnaround time | `TAT = CT - AT` | Total time in the system |
| Waiting time | `WT = TAT - BT` | Time ready but not running |
| Response time | `RT = ST - AT` | Delay before the first CPU allocation |
For a single CPU burst, these formulas assume that BT is the process's total CPU execution time. In a preemptive algorithm, a process may run several times, but its response time still uses only its first start.
Guided Example: FCFS
Consider three processes scheduled by First-Come, First-Served (FCFS). FCFS runs processes in arrival order and does not preempt the running process.
| Process | Arrival time | Burst time |
|---|---|---|
| P1 | 0 | 5 |
| P2 | 1 | 3 |
| P3 | 2 | 1 |
P1 arrives first, so it runs from time 0 to 5. P2 then runs from 5 to 8. P3 runs from 8 to 9.
Now calculate each value:
| Process | CT | TAT = CT - AT | WT = TAT - BT | RT = ST - AT |
|---|---|---|---|---|
| P1 | 5 | 5 | 0 | 0 |
| P2 | 8 | 7 | 4 | 4 |
| P3 | 9 | 7 | 6 | 6 |
The average turnaround time is (5 + 7 + 7) / 3 = 6.33. The average waiting time and response time are both 3.33.
In FCFS, a process starts only after every earlier process finishes. Therefore, for this non-preemptive example, waiting time and response time are equal. This is not generally true for Round Robin or other preemptive algorithms.
A Reliable Calculation Method
For an exam problem:
- Draw the Gantt chart first.
- Record the first start time and final completion time for every process.
- Apply the formulas separately.
- Check that
TAT = WT + BT.
processes = {
"P1": {"arrival": 0, "burst": 5, "start": 0, "completion": 5},
"P2": {"arrival": 1, "burst": 3, "start": 5, "completion": 8},
"P3": {"arrival": 2, "burst": 1, "start": 8, "completion": 9},
}
for name, p in processes.items():
turnaround = p["completion"] - p["arrival"]
waiting = turnaround - p["burst"]
response = p["start"] - p["arrival"]
print(name, turnaround, waiting, response)Exam Checklist
Track AT, BT, ST, and CT in a table. For preemptive scheduling, update remaining burst time after every execution segment, but record ST only once. A long first process can increase the waiting and response times of all later processes.
Exercise
A process arrives at time 3, first starts at time 7, completes at time 15, and has a burst time of 5. Find its turnaround, waiting, and response times.
Show answer
Turnaround time is 15 - 3 = 12. Waiting time is 12 - 5 = 7. Response time is 7 - 3 = 4.