Bird
Raised Fist0
Operating Systemsknowledge~30 mins

Scheduling criteria (turnaround time, waiting time, throughput) in Operating Systems - Mini Project: Build & Apply

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Understanding Scheduling Criteria: Turnaround Time, Waiting Time, and Throughput
๐Ÿ“– Scenario: You are managing a small computer system that runs several tasks. Each task has a specific time it needs to run (burst time). You want to understand how well your system schedules these tasks by calculating key performance measures.
๐ŸŽฏ Goal: Build a simple data structure to hold task details, set a total time limit, calculate turnaround time, waiting time, and throughput for the tasks, and finalize the summary of these scheduling criteria.
๐Ÿ“‹ What You'll Learn
Create a dictionary with task names as keys and their burst times as values.
Add a variable for the total time available for processing tasks.
Calculate turnaround time and waiting time for each task using a simple scheduling order.
Calculate throughput as the number of tasks completed per unit time.
Summarize the scheduling criteria in a final dictionary.
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Scheduling criteria like turnaround time, waiting time, and throughput help system administrators and developers understand how efficiently a computer system handles multiple tasks.
๐Ÿ’ผ Career
Knowledge of scheduling criteria is essential for roles in system administration, software development, and performance engineering to optimize resource use and improve user experience.
Progress0 / 4 steps
1
DATA SETUP: Create the tasks dictionary
Create a dictionary called tasks with these exact entries: 'Task1': 4, 'Task2': 3, 'Task3': 2, 'Task4': 1 representing the burst time for each task.
Operating Systems
Hint

Use curly braces to create a dictionary with task names as keys and numbers as values.

2
CONFIGURATION: Set the total available time
Add a variable called total_time and set it to 10 representing the total time available to run all tasks.
Operating Systems
Hint

Just create a variable and assign the number 10 to it.

3
CORE LOGIC: Calculate turnaround time and waiting time
Create two dictionaries called turnaround_time and waiting_time. Use a variable elapsed starting at 0. For each task in the order Task1, Task2, Task3, Task4, calculate turnaround time as elapsed + burst time and waiting time as elapsed. Update elapsed by adding the current task's burst time after each calculation.
Operating Systems
Hint

Use a for loop over the list of tasks in order. Keep track of elapsed time and update both dictionaries inside the loop.

4
COMPLETION: Calculate throughput and summarize criteria
Create a variable called throughput as the number of tasks divided by total_time. Then create a dictionary called scheduling_summary with keys 'Turnaround Time', 'Waiting Time', and 'Throughput' holding the respective dictionaries and value.
Operating Systems
Hint

Count the tasks with len(tasks) and divide by total_time. Then create a dictionary with the three keys and their values.

Practice

(1/5)
1. Which scheduling criterion measures the total time taken from the arrival of a process to its completion?
easy
A. Turnaround time
B. Waiting time
C. Throughput
D. Response time

Solution

  1. Step 1: Understand the definition of turnaround time

    Turnaround time is the total time from when a process arrives until it finishes execution.
  2. Step 2: Compare with other criteria

    Waiting time is only the time a process waits before starting, throughput is number of processes completed per time, and response time is time until first response.
  3. Final Answer:

    Turnaround time -> Option A
  4. Quick Check:

    Turnaround time = total process duration [OK]
Hint: Turnaround = arrival to finish total time [OK]
Common Mistakes:
  • Confusing waiting time with turnaround time
  • Mixing throughput with time durations
  • Thinking response time equals turnaround time
2. Which of the following correctly defines waiting time in process scheduling?
easy
A. Number of processes completed per unit time
B. Time from process arrival to completion
C. Time a process spends in the ready queue before execution
D. Time taken by CPU to execute the process

Solution

  1. Step 1: Define waiting time

    Waiting time is the time a process spends waiting in the ready queue before it starts running on the CPU.
  2. Step 2: Eliminate other options

    Time from process arrival to completion describes turnaround time, C describes throughput, and D is CPU burst time, not waiting time.
  3. Final Answer:

    Time a process spends in the ready queue before execution -> Option C
  4. Quick Check:

    Waiting time = time before execution [OK]
Hint: Waiting time = time before process runs [OK]
Common Mistakes:
  • Confusing waiting time with turnaround time
  • Thinking waiting time includes execution time
  • Mixing throughput with waiting time
3. Consider three processes with the following completion times (in seconds): P1=10, P2=15, P3=20. If all arrived at time 0, what is the throughput if the total time observed is 20 seconds?
medium
A. 0.20 processes per second
B. 0.15 processes per second
C. 0.10 processes per second
D. 0.25 processes per second

Solution

  1. Step 1: Calculate total processes completed

    All three processes (P1, P2, P3) completed within 20 seconds, so total completed = 3.
  2. Step 2: Calculate throughput

    Throughput = number of processes completed / total time = 3 / 20 = 0.15 processes per second.
  3. Final Answer:

    0.15 processes per second -> Option B
  4. Quick Check:

    Throughput = 3/20 = 0.15 [OK]
Hint: Throughput = completed tasks รท total time [OK]
Common Mistakes:
  • Dividing total time by number of processes instead of reverse
  • Counting incomplete processes
  • Using average completion time instead of total time
4. A scheduler reports the following for a process: Arrival time = 0, Start time = 5, Completion time = 12. The waiting time is incorrectly calculated as 7 seconds. What is the correct waiting time?
medium
A. 5 seconds
B. 7 seconds
C. 12 seconds
D. 0 seconds

Solution

  1. Step 1: Understand waiting time formula

    Waiting time = Start time - Arrival time = 5 - 0 = 5 seconds.
  2. Step 2: Identify error in reported waiting time

    The reported waiting time of 7 seconds is incorrect because it does not match the formula.
  3. Final Answer:

    5 seconds -> Option A
  4. Quick Check:

    Waiting time = start - arrival = 5 [OK]
Hint: Waiting time = start time minus arrival time [OK]
Common Mistakes:
  • Using completion time instead of start time
  • Adding instead of subtracting times
  • Confusing waiting time with turnaround time
5. A system runs 4 processes with arrival times and burst times as follows:
P1: arrival=0, burst=4
P2: arrival=1, burst=3
P3: arrival=2, burst=1
P4: arrival=3, burst=3
If the scheduler uses First-Come-First-Serve (FCFS), what is the average turnaround time?
hard
A. 3.5 seconds
B. 4.5 seconds
C. 5.0 seconds
D. 6.0 seconds

Solution

  1. Step 1: Calculate completion times using FCFS

    Process order by arrival: P1(0), P2(1), P3(2), P4(3).
    P1 completes at 0+4=4,
    P2 starts at 4, completes at 4+3=7,
    P3 starts at 7, completes at 7+1=8,
    P4 starts at 8, completes at 8+3=11.
  2. Step 2: Calculate turnaround times

    Turnaround = completion - arrival:
    P1: 4-0=4,
    P2: 7-1=6,
    P3: 8-2=6,
    P4: 11-3=8.
    Average turnaround = (4+6+6+8)/4 = 24/4 = 6.0 seconds.
  3. Final Answer:

    6.0 seconds -> Option D
  4. Quick Check:

    Average turnaround = 24/4 = 6.0 [OK]
Hint: Turnaround = completion - arrival; average = sum/number [OK]
Common Mistakes:
  • Calculating turnaround as burst time only
  • Ignoring arrival times in scheduling order
  • Mixing waiting time with turnaround time