Professional Documents
Culture Documents
P2 P3 P1
• The waiting time for P1 is 6 msec.
• The waiting time for P2 is 0 msec.
• The waiting time for P3 is 3 msec.
• The average waiting time is now (6+ 0 + 3)/3 = 3
milliseconds.
Any questions??
• Priority Scheduling(non pre-emptive)
• A priority is associated with each process, and the
CPU is allocated to the process with the highest
priority.
• Equal-priority processes are scheduled in FCFS order.
• The Gantt Chart is as follows:
• The waiting time for P1 is 6 msec.
• The waiting time for P2 is 0 msec.
• The waiting time for P3 is 16 msec.
• The waiting time for P4 is 18 msec.
• The waiting time for P5 is 01 msec.
• The average waiting time is now
(6+ 0 + 16 + 18 + 01)/5 = 8.2 milliseconds.
• Priority scheduling can be either preemptive or non
preemptive. When a process arrives at the ready
queue, its priority is compared with the priority of
the currently running process.
• A preemptive priority scheduling algorithm will
preempt the CPU if the priority of the newly arrived
process is higher than the priority of the currently
running process.
• For the following processes in ready queue, calculate
the average waiting time and TAT with pre-emptive
priority scheduling. Note that at time t= 4sec,
another process P6 with priority 0 and burst time of
2sec, joins the ready queue.
P2 P5 P6 P5 P1 P3 P4
P1 P2 P3
8msec 4msec 1msec
P1 P2 P3 P4 P5
10msec 1msec 2msec 1msec 5msec
SJF
P2 P4 P3 P5 P1
1msec 1msec 2msec 5msec 10msec
Non-preemptive priority
P2 P5 P1 P3 P4
1msec 5msec 10msec 2msec 1msec