All Exams Test series for 1 year @ ₹349 only
Question

Which of the following statement(s) is/are true about CPU scheduling algorithm?

I. Shortest remaining time first scheduling may cause starvation

II. Round Robin is better than First Come First Serve in terms of response time

The correct answer is

Both I and II

Let's analyze the given statements about CPU scheduling algorithms to determine which ones are true.

Analyzing CPU Scheduling Statement I: SRTF Starvation

Statement I says: Shortest remaining time first scheduling may cause starvation.

Shortest Remaining Time First (SRTF) is a preemptive version of the Shortest Job Next (SJN) scheduling algorithm. In SRTF, the CPU is allocated to the process with the smallest remaining execution time. If a new process arrives with a smaller remaining time than the currently executing process, the current process is preempted.

Starvation occurs when a process is indefinitely postponed and never gets to execute because other processes are always given priority.

In SRTF, if there is a continuous arrival of processes with very short execution times (or short remaining times), a longer process might keep getting preempted and never get a chance to finish its execution. New short jobs keep arriving and getting priority over the long job. This situation leads to starvation for the longer process.

Therefore, statement I is true.

Analyzing CPU Scheduling Statement II: Round Robin vs FCFS Response Time

Statement II says: Round Robin is better than First Come First Serve in terms of response time.

First Come First Serve (FCFS) is a non-preemptive scheduling algorithm where processes are executed in the order they arrive. The process that arrives first gets the CPU first and runs until it completes or performs an I/O operation.

Round Robin (RR) is a preemptive scheduling algorithm designed for time-sharing systems. Each process is given a small unit of CPU time, called a time quantum. If a process completes its execution within the time quantum, it releases the CPU. If it does not, it is preempted, and the CPU is given to the next process in the ready queue. The preempted process is then added to the end of the ready queue.

Response time is the time taken from when a request is submitted until the first response is produced. For interactive systems, a low response time is desirable so that the user feels the system is reacting quickly.

Let's compare FCFS and RR response times with a simple example:

Process Arrival Time Burst Time
P1 0 10
P2 1 2
P3 2 3

FCFS Execution:

  • P1 starts at 0, runs for 10 units.
  • P2 arrives at 1, waits.
  • P3 arrives at 2, waits.
  • P2 starts at 10, runs for 2 units.
  • P3 starts at 12, runs for 3 units.

Response Times (first time CPU is allocated):

  • P1: 0 - 0 = 0
  • P2: 10 - 1 = 9
  • P3: 12 - 2 = 10

Round Robin Execution (assume time quantum = 2):

  • P1 starts at 0, runs for 2 units (remaining burst = 8). P1 goes to the end of the queue.
  • P2 arrives at 1. Ready queue: P2, P3, P1.
  • P2 starts at 2, runs for 2 units (remaining burst = 0). P2 finishes.
  • P3 arrives at 2. Ready queue: P3, P1.
  • P3 starts at 4, runs for 2 units (remaining burst = 1). P3 goes to the end of the queue.
  • P1 starts at 6, runs for 2 units (remaining burst = 6). P1 goes to the end of the queue.
  • ... and so on.

Response Times:

  • P1: 0 - 0 = 0
  • P2: 2 - 1 = 1
  • P3: 4 - 2 = 2

Comparing the response times, RR (1, 2 for P2, P3) gives much faster initial responses to processes arriving later compared to FCFS (9, 10 for P2, P3). While RR might have a higher average turnaround time than some other algorithms for certain workloads, it is generally preferred for interactive systems because it provides a quicker response to multiple users by allowing each job a small slice of CPU time in a cyclic manner.

Therefore, statement II is true.

Conclusion

Both statement I (SRTF starvation) and statement II (RR better than FCFS response time) are true.

CPU Scheduling Revision Table

Algorithm Preemptive? Advantage Disadvantage Starvation Possible?
FCFS No Simple to understand and implement High average waiting/turnaround time, Poor response time for short jobs behind long jobs No (if jobs eventually finish)
SRTF Yes Optimal average waiting/turnaround time (for a given set of jobs) Requires knowing/estimating future burst times, Overhead of context switching, Can cause starvation Yes
Round Robin Yes Good response time, Fair allocation of CPU time Higher average turnaround time than SJN/SRTF, Performance depends on time quantum size, Overhead of context switching No (if time quantum is reasonable and queue is finite)

Additional Information on CPU Scheduling

CPU scheduling is the process of deciding which of the processes in the ready queue is to be allocated to the CPU. The goal is to maximize CPU utilization and throughput, while minimizing turnaround time, waiting time, and response time.

Key scheduling criteria include:

  • CPU Utilization: Keep the CPU as busy as possible.
  • Throughput: Number of processes completed per unit time.
  • Turnaround Time: Total time from submission to completion of a process.
  • Waiting Time: Total time a process spends waiting in the ready queue.
  • Response Time: Time from submission to the first response.

Different algorithms prioritize different criteria. FCFS is simple but can lead to the convoy effect (a short process gets stuck behind a long one). SRTF aims for minimum average times but requires burst time prediction and can starve long jobs. Round Robin provides fairness and good response time, suitable for interactive systems, but context switching adds overhead.

Other CPU scheduling algorithms include Priority Scheduling, Multilevel Queue Scheduling, and Multilevel Feedback Queue Scheduling.

Was this answer helpful?

Important Questions from Process Scheduling - Teaching

  1. Consider the following four processes with the arrival time and length of CPU burst given in milliseconds :

    ProcessArrival TimeBurst Time
    P 108
    P 214
    P 329
    P 435

    The average waiting time for preemptive SJF scheduling algorithm is

  2. Consider the following set of processes and the length of CPU burst time given in milliseconds:

    Process

    CPU Burst time (ms)

    P 1

    5

    P 2

    7

    P 3

    6

    P 4

    4

    Assume that processes being scheduled with Round-Robin Scheduling Algorithm with Time Quantum 4ms. Then the waiting time for P 4is _________ ms.

  3. Consider three intensive processes, which requires 10,20 and 30 units of time and arrive at times 0,2 and 6 respectively. how many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.

  4. Which of the following CPU scheduling algorithms is/are supported by LINUX operating system?

  5. Given CPU time slice of 2 ms and the following list of processes.

    Process

    Burst time (ms)

    Arrival time (ms)

    p 1

    3

    0

    p 2

    4

    2

    p 3

    5

    5

    Find average turnaround time and average waiting time using round-robin CPU scheduling?
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App