chapter

    Cpu Scheduling Notes for Gate Cs

    Cpu Scheduling notes for GATE CS: 42 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.

    Cpu Scheduling notes

    Chapter Roadmap: CPU Scheduling

    The CPU Scheduling Journey
    Foundations & Metrics: Arrival, Burst, Completion, Turnaround, Waiting, Response.
    SJF & SRTF: Optimal algorithms for minimizing average waiting time.
    Scheduling Properties: Preemption overhead, starvation, convoy effect.
    Round Robin (RR): Time-slicing, quantum selection, context switches.
    Priority & Multiprocessor: Diverse workloads and multi-CPU distribution.

    Topic Hero: The Core Philosophy of SJF and SRTF

    The primary objective of any scheduling algorithm is to optimize system metrics. For batch systems, the most critical metric is average waiting time.
    The Mathematical Truth: To minimize the sum of waiting times, you must execute the shortest jobs first. If you execute a long job first, all subsequent short jobs are forced to wait for the entire duration of that long job.
    • Shortest Job First (SJF): Non-preemptive. Once a process gets the CPU, it runs to completion.
    • Shortest Remaining Time First (SRTF): Preemptive. If a newly arrived process has a burst time strictly less than the remaining time of the currently running process, the CPU is snatched away.
    Note: Both algorithms are mathematically proven to give the minimum average waiting time for a given set of processes.

    Executing Non-Preemptive SJF

    Core Rule: No Preemption

    Once a process starts, it runs to completion.

    1. Identify current time .
    2. Filter processes where .
    3. Select process with minimum .
    4. Tie-breaker: If same , pick earliest (FCFS).
    5. Allocate CPU. New time . Record .
    6. Repeat until all completed.
    CPU Idle? If no processes have arrived (), CPU remains idle until the earliest remaining .

    39 more cards in this chapter

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    Level 1: Warm-up

    Three processes arrive at time zero with CPU burst times of 0.01 seconds, 15 milliseconds, and 25 milliseconds. If the scheduler uses Non-Preemptive Shortest Job First (SJF), what is the minimum achievable average waiting time in milliseconds (rounded to 2 decimal places)?

    Question 2
    Level 1: Warm-up

    Consider the following statements about CPU scheduling algorithms:

    Statement 1: Round Robin scheduling can cause starvation if the time quantum is very small.

    Statement 2: First Come First Serve (FCFS) scheduling never causes starvation.

    Which of the following is correct?

    Question 3
    Level 1: Warm-up

    For a specific process, the Turnaround Time is 15 ms and the Burst Time is 10 ms. Based on the relationship between scheduling metrics, what is the maximum possible value of the Response Time for this process in milliseconds?

    Question 4
    Level 1: Warm-up

    Which of the following statements accurately describes the preemption condition in Shortest Remaining Time First (SRTF) scheduling?

    Question 5
    Level 1: Warm-up

    Consider the following statements about CPU scheduling algorithms:

    Statement 1: For processes arriving at different times, Shortest Remaining Time First (SRTF) always gives lower or equal average waiting time compared to Non-Preemptive SJF.

    Statement 2: For processes arriving at the same time, SRTF and Non-Preemptive SJF produce different Gantt charts.

    Which of the following is correct?

    Question 6
    Level 1: Warm-up

    A process has a base priority of 8. The aging function increases its priority by 2 for every 5 time units it waits. If the process has waited for 10 time units, what is its effective priority?

    Question 7
    Level 1: Warm-up

    In a Priority Scheduling system, what is the maximum consequence for a low-priority process if a continuous stream of higher-priority processes arrives?

    Question 8
    Level 1: Warm-up

    A process has a base priority of 10. The aging function increases its priority by 3 for every 4 time units it waits. If the process has waited for 12 time units, what is its effective priority?

    Question 9
    Level 1: Warm-up

    Assertion (A): When all processes arrive at time , Shortest Job First (SJF) and Shortest Remaining Time First (SRTF) scheduling produce identical Gantt charts and the same average waiting time.

    Reason (R): Preemption in SRTF occurs only when a newly arrived process has a strictly smaller remaining burst time than the currently running process.

    Question 10
    Level 1: Warm-up

    Three processes arrive with the following arrival times (AT) and burst times (BT) in milliseconds: : AT = 0, BT = 6; : AT = 1, BT = 3; : AT = 2, BT = 1. Compute the ratio of the average waiting time under Non-Preemptive Shortest Job First (SJF) to the average waiting time under preemptive Shortest Remaining Time First (SRTF). Round your answer to two decimal places.

    Free preview ends here

    Login to view the complete notes

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Explore complete test series, official past papers, and chapter-wise study tools.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Cpu Scheduling Notes for GATE CS

    Cpu Scheduling notes for GATE CS: 42 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.

    Chapter Roadmap: CPU Scheduling

    The CPU Scheduling Journey
    Foundations & Metrics: Arrival, Burst, Completion, Turnaround, Waiting, Response.
    SJF & SRTF: Optimal algorithms for minimizing average waiting time.
    Scheduling Properties: Preemption overhead, starvation, convoy effect.
    Round Robin (RR): Time-slicing, quantum selection, context switches.
    Priority & Multiprocessor: Diverse workloads and multi-CPU distribution.

    Topic Hero: The Core Philosophy of SJF and SRTF

    The primary objective of any scheduling algorithm is to optimize system metrics. For batch systems, the most critical metric is average waiting time.
    The Mathematical Truth: To minimize the sum of waiting times, you must execute the shortest jobs first. If you execute a long job first, all subsequent short jobs are forced to wait for the entire duration of that long job.
    • Shortest Job First (SJF): Non-preemptive. Once a process gets the CPU, it runs to completion.
    • Shortest Remaining Time First (SRTF): Preemptive. If a newly arrived process has a burst time strictly less than the remaining time of the currently running process, the CPU is snatched away.
    Note: Both algorithms are mathematically proven to give the minimum average waiting time for a given set of processes.

    Executing Non-Preemptive SJF

    Core Rule: No Preemption

    Once a process starts, it runs to completion.

    1. Identify current time .
    2. Filter processes where .
    3. Select process with minimum .
    4. Tie-breaker: If same , pick earliest (FCFS).
    5. Allocate CPU. New time . Record .
    6. Repeat until all completed.
    CPU Idle? If no processes have arrived (), CPU remains idle until the earliest remaining .

    Executing Preemptive SRTF

    Core Rule: Preemption on Strictly Smaller RBT
    1. Maintain Remaining Burst Time (RBT) table.
    2. At time , filter processes with and .
    3. Select process with minimum RBT.
    4. Tie-breaker: If RBTs equal, earliest continues (No preemption).
    5. Run for 1 unit (or until next arrival). Decrease RBT by 1.
    6. If , record . Check new arrivals.
    Crucial Condition: Preempt ONLY if . If equal, do NOT preempt.

    Cpu Scheduling: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Operating System NAT

    Three processes arrive at time zero with CPU burst times of 0.01 seconds, 15 milliseconds, and 25 milliseconds. If the scheduler uses Non-Preemptive Shortest Job First (SJF), what is the minimum achievable average waiting time in milliseconds (rounded to 2 decimal places)?

    Correct Answer:

    11.67

    Step-by-Step Solution

    Key idea: Convert all burst times to the same unit, then apply SJF to minimize average waiting time.

    Step 1: Convert all burst times to milliseconds:

    • : 0.01 seconds = 10 ms
    • : 15 ms
    • : 25 ms

    Step 2: Sort by burst time (SJF order):

    • : 10 ms
    • : 15 ms
    • : 25 ms

    Step 3: Calculate waiting times:

    • : WT = 0 (runs first)
    • : WT = 10 (waits for )
    • : WT = 10 + 15 = 25 (waits for and )

    Step 4: Calculate average waiting time:

    Answer: 11.67

    Question 2 · Operating System MCQ

    Consider the following statements about CPU scheduling algorithms:

    Statement 1: Round Robin scheduling can cause starvation if the time quantum is very small.

    Statement 2: First Come First Serve (FCFS) scheduling never causes starvation.

    Which of the following is correct?

    1. A.

      Both Statement 1 and Statement 2 are true

    2. B.

      Statement 1 is true, but Statement 2 is false

    3. C.

      Statement 1 is false, but Statement 2 is true

    4. D.

      Both Statement 1 and Statement 2 are false

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a bounding question testing the properties matrix of scheduling algorithms.

    Step 1: Evaluate Statement 1. Round Robin gives every process a fixed time slice in a cyclic order. No process is indefinitely blocked, regardless of the time quantum size. A small quantum increases context switch overhead, but does not cause starvation. Thus, Statement 1 is false.

    Step 2: Evaluate Statement 2. FCFS executes processes in the exact order they arrive. Every process will eventually reach the front of the queue and execute. Thus, it never causes starvation. Statement 2 is true.

    Step 3: Conclusion: Statement 1 is false, but Statement 2 is true.

    Answer: C

    Question 3 · Operating System MCQ

    For a specific process, the Turnaround Time is 15 ms and the Burst Time is 10 ms. Based on the relationship between scheduling metrics, what is the maximum possible value of the Response Time for this process in milliseconds?

    1. A.

      5

    2. B.

      15

    3. C.

      10

    4. D.

      25

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: Response Time (RT) is bounded by Waiting Time (WT). We must first find WT.

    Step 1: Calculate Waiting Time using the formula: WT = TAT - BT.

    Step 2: Substitute the values: WT = 15 - 10 = 5 ms.

    Step 3: Recognize that Waiting Time includes the initial Response Time plus any additional time spent waiting in the ready queue after preemption.

    Step 4: Therefore, RT ≤ WT. The maximum possible value for RT occurs when there is no preemption, meaning RT = WT.

    Answer: 5

    Question 4 · Operating System MCQ

    Which of the following statements accurately describes the preemption condition in Shortest Remaining Time First (SRTF) scheduling?

    1. A.

      A newly arrived process preempts the running process if its burst time is less than or equal to the remaining time of the running process.

    2. B.

      A newly arrived process preempts the running process only if its burst time is strictly less than the remaining time of the running process.

    3. C.

      A newly arrived process always preempts the running process regardless of burst times.

    4. D.

      Preemption in SRTF occurs based on the arrival time order, not the remaining burst time.

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: SRTF preemption requires a strict inequality to justify the overhead of a context switch.

    Step 1: Recall the definition of SRTF: it is the preemptive version of SJF.

    Step 2: Identify the trigger for preemption: a new process arrives.

    Step 3: Apply the condition: preemption occurs ONLY IF the new process's burst time is strictly less than (<) the remaining burst time of the currently running process.

    Step 4: Note that if the times are equal, no preemption occurs to avoid unnecessary context switch overhead.

    Answer: B

    Question 5 · Operating System MCQ

    Consider the following statements about CPU scheduling algorithms:

    Statement 1: For processes arriving at different times, Shortest Remaining Time First (SRTF) always gives lower or equal average waiting time compared to Non-Preemptive SJF.

    Statement 2: For processes arriving at the same time, SRTF and Non-Preemptive SJF produce different Gantt charts.

    Which of the following is correct?

    1. A.

      Statement 1 is true, Statement 2 is false

    2. B.

      Statement 1 is false, Statement 2 is true

    3. C.

      Both statements are true

    4. D.

      Both statements are false

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: Understand when SRTF and SJF differ and when they give the same results.

    Step 1: Analyze Statement 1:

    • When processes arrive at different times, SRTF can preempt a running process to serve a newly arrived shorter process.
    • SJF cannot preempt, so short processes may wait behind long ones.
    • Therefore, SRTF always gives average waiting time compared to SJF for staggered arrivals.
    • Statement 1 is TRUE.

    Step 2: Analyze Statement 2:

    • When all processes arrive at the same time (), no new processes arrive to cause preemption.
    • Both SRTF and SJF will execute processes in the same order (sorted by burst time).
    • They produce identical Gantt charts and identical metrics.
    • Statement 2 is FALSE.

    Step 3: Conclusion:

    • Statement 1 is true
    • Statement 2 is false

    Answer: A

    Question 6 · Operating System NAT

    A process has a base priority of 8. The aging function increases its priority by 2 for every 5 time units it waits. If the process has waited for 10 time units, what is its effective priority?

    Correct Answer:

    12.00

    Step-by-Step Solution

    Key idea: This is a direct formula application question testing the concept of aging in scheduling.

    Step 1: Identify the base priority, which is 8.

    Step 2: Calculate the number of aging intervals. The process waited for 10 time units, and aging occurs every 5 time units. Number of intervals = 10 / 5 = 2.

    Step 3: Calculate the priority increase. Increase = 2 intervals * 2 priority units/interval = 4.

    Step 4: Calculate effective priority. Effective Priority = Base Priority + Increase = 8 + 4 = 12.

    Answer: 12.00

    Question 7 · Operating System MCQ

    In a Priority Scheduling system, what is the maximum consequence for a low-priority process if a continuous stream of higher-priority processes arrives?

    1. A.

      It receives a larger time quantum

    2. B.

      It experiences indefinite blocking (starvation)

    3. C.

      It triggers the convoy effect

    4. D.

      It reduces the overall context switch overhead

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is an observation question testing the fundamental flaw of Priority Scheduling.

    Step 1: Analyze the scenario: a low-priority process is in the ready queue, and higher-priority processes continuously arrive.

    Step 2: In Priority Scheduling, the CPU is always allocated to the highest priority ready process.

    Step 3: Because higher-priority processes keep arriving, the low-priority process will never get a chance to execute.

    Step 4: This condition is known as indefinite blocking or starvation.

    Answer: B

    Question 8 · Operating System NAT

    A process has a base priority of 10. The aging function increases its priority by 3 for every 4 time units it waits. If the process has waited for 12 time units, what is its effective priority?

    Correct Answer:

    19.00

    Step-by-Step Solution

    Key idea: This is a direct formula application question testing the concept of aging in scheduling.

    Step 1: Identify the base priority, which is 10.

    Step 2: Calculate the number of aging intervals. The process waited for 12 time units, and aging occurs every 4 time units. Number of intervals = 12 / 4 = 3.

    Step 3: Calculate the priority increase. Increase = 3 intervals * 3 priority units/interval = 9.

    Step 4: Calculate effective priority. Effective Priority = Base Priority + Increase = 10 + 9 = 19.

    Answer: 19.00

    Question 9 · Operating System MCQ

    Assertion (A): When all processes arrive at time , Shortest Job First (SJF) and Shortest Remaining Time First (SRTF) scheduling produce identical Gantt charts and the same average waiting time.

    Reason (R): Preemption in SRTF occurs only when a newly arrived process has a strictly smaller remaining burst time than the currently running process.

    1. A.

      Both A and R are true and R is the correct explanation of A

    2. B.

      Both A and R are true but R is NOT the correct explanation of A

    3. C.

      A is true but R is false

    4. D.

      A is false but R is true

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a comparison question testing the relationship between SJF and SRTF under specific arrival conditions.

    Step 1: Evaluate Assertion (A). When all processes arrive at , no new processes arrive during execution. Since SRTF preempts only on new arrivals with shorter remaining time, and there are no new arrivals, SRTF never preempts. Thus, SRTF behaves exactly like non-preemptive SJF, producing identical Gantt charts and metrics. A is true.

    Step 2: Evaluate Reason (R). The preemption condition in SRTF is: preempt if and only if a newly arrived process has strictly smaller remaining burst time. This is the standard definition. R is true.

    Step 3: Check if R explains A. Yes. The absence of new arrivals (stated in A) means the preemption condition (stated in R) is never triggered, which is why SJF and SRTF are identical. R directly explains A.

    Answer: A

    Common trap: Students ignore the constraint "all arrive at " and assume SRTF always preempts, leading them to mark D.

    Question 10 · Operating System NAT

    Three processes arrive with the following arrival times (AT) and burst times (BT) in milliseconds: : AT = 0, BT = 6; : AT = 1, BT = 3; : AT = 2, BT = 1. Compute the ratio of the average waiting time under Non-Preemptive Shortest Job First (SJF) to the average waiting time under preemptive Shortest Remaining Time First (SRTF). Round your answer to two decimal places.

    Correct Answer:

    2.00

    Step-by-Step Solution

    Key idea: This is a comparison question testing the optimality difference between SJF and SRTF when processes arrive at staggered times.

    Step 1: Compute average waiting time under SJF (non-preemptive).

    • At : Only available. runs from 0 to 6.
    • At : (BT=3) and (BT=1) available. has shorter burst, runs 6 to 7.
    • At : runs 7 to 10.
    • Completion times: , , .
    • Waiting times: ; ; .
    • Average WT (SJF) = .

    Step 2: Compute average waiting time under SRTF (preemptive).

    • At : starts. Remaining burst time (RBT): .
    • At : arrives (BT=3). RBT=5, BT=3. Since , preempt. runs.
    • At : arrives (BT=1). RBT=2, BT=1. Since , preempt. runs.
    • At : finishes. Ready: (RBT=5), (RBT=2). runs.
    • At : finishes. runs.
    • At : finishes.
    • Completion times: , , .
    • Waiting times: ; ; .
    • Average WT (SRTF) = .

    Step 3: Compute ratio.

    Ratio = .

    Answer: 2.00

    Common trap: Students ignore the staggered arrivals and assume SJF = SRTF, leading to ratio = 1.00.

    More notes in this unit