With P1, P2, P3, and P4 a total of 4 processes go into the ready queue sequentially, they require processor time and priority levels as follows:
Process uses processor Time (seconds) Precedence number
P1 20 3
P2 30 5
P3 10 2
P4 5 4
to ignore the time it takes to schedule, answer the following questions:
(1) write out the order of process execution selected by the "first come first service" and "Non preemptive priority" scheduling algorithms.
(2) Under the above two algorithms, the waiting time and average wait time of each process in the ready queue are calculated separately.
Answer: (1) The scheduling algorithm of 4 processes is P1, P2, P3, P4.
The scheduling order of 4 processes is P2, P4, P1, P3 with the non-preemptive priority number scheduling algorithm.
(2) The waiting time of each process in the ready queue is as follows: The first-come-first service scheduling algorithm.
p1:0 sec
P2:0+20=20 sec
P3:0+20+30=50 sec
P4:0+20+30+10=60 sec
Average wait Time: (0+20+50+60)/4=32.5 sec
The waiting time of each process in the ready queue is based on the non-preemptive priority number scheduling algorithm;
P1:30+5=35 sec
p2:0 sec
P3:20+30+5=55 sec
P4:30 sec
Average wait Time: (35+0+55+30)/4=30 sec