Consider three processes P1, P2, and P3 with the following CPU burst times: Burst times for P1: 14, 12, 17, Burst times for P2: 2, 2, 2, 3, 2, 2, 2, 3, Burst times for P3: 6, 3, 8, 2, 1, 3, 4, 1, 9, 7. All three arrive at time 0, in order P1, P2, P3. Each CPU burst is followed by an I/O operation taking 6 time units, except for the last burst after which the process terminates. Assume that overhead time for process switching and scheduling functions are negligible (assumed to be 0). Multi-level feedback queuing using three queues with the following parameters: Queue 0 quantum of 2 time units (after which process is moved to Queue 1). Queue 1 quantum of 4 time units (after which process is moved to Queue 2). Queue 2 FCFS. All process that becomes ready is added to Queue 0. A process that arrives in Queue 0 preempts any executing process that belongs to either Queue 1 or Queue 2. Processes in Queue 1 are allocated to the CPU only when Queue 0 is empty. Processes in Queue 2 are allocated to the CPU only with both Queue 0 and Queue 1 are empty. What is the average turnaround time. Write the answer in up to integer; round off and don t write any additional character. Examples of incorrect answers are 3.2, 3 ms, 12 sec, etc."10:17 a.m.
Question
Consider three processes P1, P2, and P3 with the following CPU burst times: Burst times for P1: 14, 12, 17, Burst times for P2: 2, 2, 2, 3, 2, 2, 2, 3, Burst times for P3: 6, 3, 8, 2, 1, 3, 4, 1, 9, 7. All three arrive at time 0, in order P1, P2, P3. Each CPU burst is followed by an I/O operation taking 6 time units, except for the last burst after which the process terminates. Assume that overhead time for process switching and scheduling functions are negligible (assumed to be 0). Multi-level feedback queuing using three queues with the following parameters: Queue 0 quantum of 2 time units (after which process is moved to Queue 1). Queue 1 quantum of 4 time units (after which process is moved to Queue 2). Queue 2 FCFS. All process that becomes ready is added to Queue 0. A process that arrives in Queue 0 preempts any executing process that belongs to either Queue 1 or Queue 2. Processes in Queue 1 are allocated to the CPU only when Queue 0 is empty. Processes in Queue 2 are allocated to the CPU only with both Queue 0 and Queue 1 are empty. What is the average turnaround time. Write the answer in up to integer; round off and don t write any additional character. Examples of incorrect answers are 3.2, 3 ms, 12 sec, etc."10:17 a.m.
Solution
To solve this problem, we need to simulate the execution of the processes according to the rules of the multi-level feedback queue.
Here is the step-by-step calculation:
-
At time 0, all processes arrive. P1 goes to Queue 0 because it's the first in order. It executes for 2 time units (the quantum of Queue 0) and then moves to Queue 1. The time is now 2.
-
P2 now goes to Queue 0 and executes for 2 time units (its entire burst time), then goes to I/O for 6 time units. The time is now 4.
-
P3 goes to Queue 0 and executes for 2 time units, then moves to Queue 1. The time is now 6.
-
P1, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 10.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 12.
-
P3, which is in Queue 1, executes for 2 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 14.
-
P1, which is in Queue 2, executes for 8 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 22.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 24.
-
P3 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 26.
-
P1 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 28.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 30.
-
P3, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 34.
-
P1, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 38.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 40.
-
P3, which is in Queue 2, executes for 2 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 42.
-
P1, which is in Queue 2, executes for 6 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 48.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 50.
-
P3 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 52.
-
P1 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 54.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 56.
-
P3, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 60.
-
P1, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 64.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 66.
-
P3, which is in Queue 2, executes for 2 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 68.
-
P1, which is in Queue 2, executes for 6 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 74.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 76.
-
P3 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 78.
-
P1 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 80.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 82.
-
P3, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 86.
-
P1, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 90.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 92.
-
P3, which is in Queue 2, executes for 1 time unit (the rest of its burst time), then goes to I/O for 6 time units. The time is now 93.
-
P1, which is in Queue 2, executes for 5 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 98.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 100.
-
P3 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 102.
-
P1 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 104.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 106.
-
P3, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 110.
-
P1, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 114.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 116.
-
P3, which is in Queue 2, executes for 3 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 119.
-
P1, which is in Queue 2, executes for 5 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 124.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 126.
-
P3 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 128.
-
P1 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 130.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 132.
-
P3, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 136.
-
P1, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 140.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 142.
-
P3, which is in Queue 2, executes for 4 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 146.
-
P1, which is in Queue 2, executes for 5 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 151.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 153.
-
P3 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 155.
-
P1 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 157.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 159.
-
P3, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 163.
-
P1, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 167.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 169.
-
P3, which is in Queue 2, executes for 1 time unit (the rest of its burst time), then goes to I/O for 6 time units. The time is now 170.
-
P1, which is in Queue 2, executes for 5 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 175.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 177.
-
P3 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 179.
-
P1 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 181.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 183.
-
P3, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 187.
-
P1, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 191.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 193.
-
P3, which is in Queue 2, executes for 9 time units (the rest of its burst time), then terminates. The time is now 202.
-
P1, which is in Queue 2, executes for 5 time units (the rest of its burst time), then goes to I/O for 6 time units. The time is now 207.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 209.
-
P1 comes back from I/O and goes to Queue 0, executing for 2 time units, then moves to Queue 1. The time is now 211.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 213.
-
P1, which is in Queue 1, executes for 4 time units (the quantum of Queue 1) and then moves to Queue 2. The time is now 217.
-
P2 comes back from I/O and goes to Queue 0, executing for 2 time units, then goes to I/O for 6 time units. The time is now 219.
-
P1, which is in Queue 2, executes for 7 time units (the rest of its burst time), then terminates. The time is now 226.
-
P2 comes back from I/O and goes to Queue 0, executing for 3 time units (the rest of its burst time), then terminates. The time is now 229.
The turnaround time for each process is the time it terminates minus the time it arrived. Since all processes arrived at time 0, the turnaround time for each process is just the time it terminates. So, the turnaround times are:
- P1: 226
- P2: 229
- P3: 202
The average turnaround time is the sum of the turnaround times divided by the number of processes, which is (226 + 229 + 202) / 3 = 219.
So, the average turnaround time is 219.
Similar Questions
Consider the following set of processes, with the length of the CPU burstgiven in milliseconds:Process Burst Time PriorityP1 2 2P2 1 1P3 8 4P4 4 2P5 5 3The processes are assumed to have arrived in the order P1, P2, P3, P4, P5,all at time 0.a. Draw four Gantt charts that illustrate the execution of these processes using thefollowing scheduling algorithms: FCFS, SJF, nonpreemptive priority (a larger prioritynumber implies a higher priority), and RR (quantum = 2).b. What is the turnaround time of each process for each of the schedulingalgorithms in part a?c. What is the waiting time of each process for each of these scheduling algorithms?d. Which of the algorithms results in the minimum average waiting time (over allprocesses)?
Consider the following set of processes, with the length of the CPU burst given in milliseconds:Process Burst Time PriorityP1 2 2P2 1 1P3 3 4P4 4 2The processes are assumed to have arrived in the order P1, P2, P3, P4, P5,all at time 0. What is the turnaround time of each process for the nonpreemptive Priority scheduling algorithms (a larger priority number implies a higher priority)?A.5, 10, 3, 9B.2, 3, 6, 10C.3, 1, 6, 10D.2, 3, 8, 10
Consider the following set of processes :Process Priority Burst ArrivalP1 3 24 0P2 1 30P3 2 30The waiting time of all processes using the RR scheduling algorithms with quantum = 3 is:A.30B.6C.24D.12
Odd uid: consider the three processes with arrival and burst time asProcess Arrival time Burst timeP1 0 9P2 1 4P3 2 7The pre-emptive shortest job first scheduling is used. Scheduling is carried out at arrival orcompletion of processes. What is the average waiting time for the three processes?Also find TTAT.
Q5. Consider the set of 6 processes whose arrival time and burst time are given below-Arrival time Burst timeP1 0 6P2 1 7P3 2 8P4 3 10P5 4 3P6 5 4If the CPU scheduling policy is Round Robin with time quantum = 3, calculate the average waiting time andaverage turnaround time. For the given scheduling Algorithm (a) FCFS (b) SJF (c) SRTF
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.