Question: can you generate the output like this for RR ? RR - 4 0 1 2 3 4 5 6 7 8 9 0 1
can you generate the output like this for RR
RR
A
B
C
D
E
import java.io;
import java.util.;
public class SchedulerDriver
void roundRobinSchedulerArrayList processNames, ArrayList startTime, ArrayList duration,
int quantum
int n processNames.size;
int remainingTime new intn; Remaining time for each process
int completionTime new intn; Completion time for each process
int turnAroundTime new intn; Turnaround time for each process
int waitingTime new intn; Waiting time for each process
ArrayList completedProcesses new ArrayList; Track completed processes
Initialize remaining time with the durations
for int i ; i n; i
remainingTimei duration.geti;
int currentTime ; Current time
int index ; Index of the current process
Keep iterating until all processes are completed
while completedProcesses.containsAllprocessNames
if remainingTimeindex
Process is not yet completed
if remainingTimeindex quantum
Process executes for the quantum
currentTime quantum;
remainingTimeindex quantum;
else
Process executes for the remaining time
currentTime remainingTimeindex;
remainingTimeindex;
completionTimeindex currentTime;
completedProcesses.addprocessNamesgetindex;
Move to the next process
index index n;
Calculate turnaround time and waiting time for each process
for int i ; i n; i
turnAroundTimei completionTimei startTime.geti;
waitingTimei turnAroundTimei duration.geti;
Display results or perform further processing
System.out.printlnRound Robin Scheduler Output";
for int i ; i n; i
System.out.printlnProcess: processNames.geti
Turnaround Time: turnAroundTimei
Waiting Time: waitingTimei;
void RRSchedulerArrayList processNames, ArrayList startTime, ArrayList duration, int timeQuantum
Queue queue new LinkedList; Queue to store process indexes
ArrayList remainingTime new ArrayListduration; Copy of duration
int currentTime ; Current time
int n processNames.size; Number of processes
Initialize remaining time and add all processes to the queue
for int i ; i n; i
queue.offeri;
Round Robin scheduling algorithm
while queue.isEmpty
int processIndex queue.poll; Get the process at the front of the queue
int executeTime Math.mintimeQuantum remainingTime.getprocessIndex; Execute for time quantum or remaining time
Update current time and remaining time
currentTime executeTime;
remainingTime.setprocessIndex remainingTime.getprocessIndex executeTime;
Print the execution of the process
System.out.printlnprocessNamesgetprocessIndex currentTime;
Readd the process to the queue if it's not completed
if remainingTimegetprocessIndex
queue.offerprocessIndex;
public static void mainString args throws FileNotFoundException
SchedulerDriver sd new SchedulerDriver;
Scanner scan new Scannernew Filejobstxt;
ArrayList processNames new ArrayList;
ArrayList startTime new ArrayList;
ArrayList duration new ArrayList;
while scanhasNextLine
String line scan.nextLine;
String tokens line.splitt;
processNames.addtokens;
startTime.addIntegerparseInttokens;
duration.addIntegerparseInttokens;
System.out.printlnRR Scheduler Output";
sdRRSchedulerprocessNames startTime, duration, ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
