Scheduling criteria (turnaround time, waiting time, throughput) in Operating Systems - Time & Space Complexity
When we analyze scheduling criteria like turnaround time, waiting time, and throughput, we want to understand how the time taken by the system changes as the number of processes grows.
We ask: How does the system's work increase when more tasks need scheduling?
Analyze the time complexity of calculating scheduling criteria for a list of processes.
for each process in process_list:
calculate turnaround_time = completion_time - arrival_time
calculate waiting_time = turnaround_time - burst_time
calculate throughput = total_processes / total_time
This code calculates turnaround time and waiting time for each process, then computes throughput for all processes.
Look for repeated steps that take most time.
- Primary operation: Looping through each process to calculate turnaround and waiting times.
- How many times: Once for every process in the list.
As the number of processes increases, the calculations grow in a simple way.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | About 10 calculations for turnaround and waiting times |
| 100 | About 100 calculations |
| 1000 | About 1000 calculations |
Pattern observation: The work grows directly with the number of processes, doubling the processes doubles the work.
Time Complexity: O(n)
This means the time to calculate scheduling criteria grows in a straight line with the number of processes.
[X] Wrong: "Calculating turnaround and waiting times takes the same time no matter how many processes there are."
[OK] Correct: Each process needs its own calculation, so more processes mean more work and more time.
Understanding how scheduling calculations scale helps you explain system performance clearly and shows you grasp how operating systems handle many tasks efficiently.
"What if we had to recalculate waiting times every time a new process arrives? How would that affect the time complexity?"