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

Consider the following set of processes assumed to have arrived at time 0 in order $P_1, P_2, P_3, P_4$ and $P_5$ with the length of CPU burst given in Milliseconds.
ProcessBurst TimePriority
$P_1$103
$P_2$11
$P_3$24
$P_4$15
$P_5$52
What is the average waiting time (in milliseconds) using priority scheduling.

The correct answer is
8.2

Priority Scheduling Average Waiting Time Calculation

This solution calculates the average waiting time for processes using non-preemptive priority scheduling. It assumes a lower numerical value indicates a higher priority.

Process Details

Process CPU Burst Time (ms) Priority Arrival Time (ms)
P1 10 3 0
P2 1 1 0
P3 2 4 0
P4 1 5 0
P5 5 2 0

Execution Order Determination

Processes are scheduled based on priority. Lower numbers mean higher priority. All arrive at time 0, so the execution order is determined solely by priority.

  • Priority 1: P2
  • Priority 2: P5
  • Priority 3: P1
  • Priority 4: P3
  • Priority 5: P4

The non-preemptive execution sequence is: P2 → P5 → P1 → P3 → P4.

Calculating Individual Waiting Times

Waiting Time = Start Time - Arrival Time. Since all processes arrive at time 0, Waiting Time = Start Time.

Process Burst Time (ms) Priority Start Time (ms) Waiting Time (ms) Completion Time (ms)
P2 1 1 0 0 1
P5 5 2 1 1 6
P1 10 3 6 6 16
P3 2 4 16 16 18
P4 1 5 18 18 19

Average Waiting Time Computation

Sum the waiting times of all processes and divide by the total number of processes.

  • Total Waiting Time = 0 + 1 + 6 + 16 + 18 = 41 ms
  • Average Waiting Time = $ \frac{\text{Total Waiting Time}}{\text{Number of Processes}} $
  • Average Waiting Time = $ \frac{41}{5} $ ms
  • Average Waiting Time = 8.2 ms
Was this answer helpful?

Important Questions from CPU Scheduling

  1. A computer has two processors, $M_1$ and $M_2$. Four processes $P_1, P_2, P_3, P_4$ with CPU bursts of 20, 16, 25, and 10 milliseconds, respectively, arrive at the same time and these are the only processes in the system. The scheduler uses non-preemptive priority scheduling, with priorities decided as follows:
    • $M_1$ uses priority of execution for the processes as, $P_1 > P_3 > P_2 > P_4$, i.e., $P_1$ and $P_4$ have highest and lowest priorities, respectively.
    • $M_2$ uses priority of execution for the processes as, $P_2 > P_3 > P_4 > P_1$, i.e., $P_2$ and $P_1$ have highest and lowest priorities, respectively.
    A process $P_i$ is scheduled to a processor $M_k$, if the processor is free and no other process $P_j$ is waiting with higher priority. At any given point of time, a process can be allocated to any one of the free processors without violating the execution priority rules. Ignore the context switch time. What will be the average waiting time of the processes in milliseconds?
  2. Consider the following table about processes, their burst time and arrival time
     

    ProcessBurst TimeArrival Time
    P1090
    P2300
    P3040
    P4082
    P5116


    Now which of the process shall finish second last as per the respective GANTT charts for the non- preemptive SJF and Round Robin (time quantum = 10) scheduling methods.

  3. Consider the following processes with CPU Burst time P1, P2, P3 arrived at time 0.
    ProcessCPU Burst Time (MS)
    P124
    P23
    P33

    What is the average waiting time of these processes executed using FCFS algorithm.
  4. A scheduling Algorithm assigns priority proportional to the waiting time of a process. Every process starts with priority zero (lowest priority). The scheduler reevaluates the process priority for every ‘T’ time units and decides next process to be scheduled. If the process have no I/O operations and all arrive at time zero, then the scheduler implements _________ criteria.
  5. Consider a CPU that has to execute two types of processes. The first type, Actuators (A), requires a CPU burst of 6 seconds. The second type, Controllers (C), requires a CPU burst of 8 seconds. A new process of type A arrives at time $t = 10$, 20, 30, 40, and 50 (in seconds). Similarly, a new process of type C arrives at time $t = 11$, 22, 33, 44, and 55 (in seconds). The CPU scheduling policy is First Come First Serve (FCFS). The first process of type A starts running at $t = 10$ seconds. The average waiting time (in seconds) for the 10 processes is ___________. (rounded off to one decimal place)
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