please explain. Consider a multilevel feedback queue shown below. Assuming that
ID: 3902449 • Letter: P
Question
please explain.
Consider a multilevel feedback queue shown below. Assuming that the following processes are the only ones that exist, determine the completion time for each of the processes. Assume that each queue is following FCFS scheduling policy. CPU first schedules all processes in the top queue (Quantum-8) before scheduling processes in queue 2 (Quantum-16), and only then it will schedule processes in queue 3 (FCFS). Look at figure below. Process CPU Burst Arrival Priority time 25 20 15 10 time P1 P2 P3 P4 P5 10 15 20 25 2 quantum 8 quantum 16 FCfSExplanation / Answer
Implemented Source Code:-
--------------------------------
package com.challenges;
import java.util.Scanner;
class ProcessArray2
{
int wait;
int arrivaltime;
int bursttime;
int turnAround;
int completionTime = 0;
ProcessArray2(int arrivaltime,int bursttime)
{
this.arrivaltime=arrivaltime;
this.bursttime = bursttime;
}
}
public class FCFS
{
public static void main(String[] args)
{
Scanner sc = new Scanner( System.in );
int arrival,burst,a=0;
float AverageWaiting=0,AverageTurnOver=0;
System.out.println("Enter the number of processes:");
int noofprocesses = sc.nextInt();
ProcessArray[] process = new ProcessArray[noofprocesses];
for(int i=0;i<noofprocesses;i++)
{
System.out.println("Please Enter Arrival time: ");
arrival=sc.nextInt();
System.out.println("Please Enter Burst Time: ");
burst=sc.nextInt();
process[i] = new ProcessArray(arrival,burst);
}
for(int i=0;i<process.length;i++)
{
a=a+process[i].bursttime;
process[i].completionTime=a;
process[i].turnAround = process[i].completionTime - process[i].arrivaltime;
process[i].wait = process[i].turnAround - process[i].bursttime;
System.out.println("Process "+i+":");
System.out.println("Turnaround Completion waiting");
AverageWaiting=AverageWaiting+process[i].wait;
AverageTurnOver=AverageTurnOver+process[i].turnAround;
System.out.println(process[i].turnAround+" "+process[i].completionTime+" "+process[i].wait);
}
System.out.println("The Average Waiting Time is:"+(AverageWaiting/noofprocesses));
System.out.println("The TurnOver Time is:"+(AverageTurnOver/noofprocesses));
sc.close();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.