Question: input for roundRobin scheduler: quantum = 1 A 0 3 B 2 6 C 4 4 D 6 5 E 8 2 expected output: A
input for roundRobin scheduler: quantum
A
B
C
D
E
expected output: A A B A B C B D C B E D C B E D C B D D
output generated: A A B A B C D B C D E B C D E B C D B D
void RRSchedulerArrayList processNames, ArrayList arrivalTime,
ArrayList serviceTime, 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
Initialize remaining time with the service times
for int i ; i n; i
remainingTimei serviceTime.geti;
int currentTime ; Current time
int completedProcesses ; Count of completed processes
Keep iterating until all processes are completed
while completedProcesses n
boolean anyProcessExecuted false; Flag to track if any process executed in this time unit
for int i ; i n; i
if arrivalTimegeti currentTime && remainingTimei Process can be started
anyProcessExecuted true; Set the flag to true indicating at least one process executed
int executionTime Math.minquantum remainingTimei; Determine execution time for the process
remainingTimei executionTime; Update remaining time
for int j ; j executionTime; j Print execution timeline
System.out.printprocessNamesgeti;
currentTime executionTime; Update current time
if remainingTimei Process completed
completionTimei currentTime; Set completion time
completedProcesses; Increment completed processes count
If no process executed in this time unit, move the current time forward
if anyProcessExecuted
currentTime;
what did I do wrong?
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
