0

i have an arraylist named "processes" that holds objects (num, arrival, burst), which is also sorted by arrival time(first to last). I have to produce the desired output, i was able to figure out the algorithm for first come first served, but i am having a lot of trouble with the Round robin one. I also have a queue sorted by arrival time, if thats perhaps an easier alternative? any help would be appreciated, thanks!

this is the input file i am reading, parsing it, creating the arraylist of objects from.

input

this is the output. i used a selected and finished variables for fcfs, i supposed we have to use the same for this one

output

Community
  • 1
  • 1
dre
  • 35
  • 4

1 Answers1

0

For Round Robin you will need to cycle through the list of your processes. Consider this pseudocode:

  while queue.isNotEmpty:
    For each ProcessId in Processes:
       Find the oldest entry for that process in your FIFO
       Execute that entry
    Reset to beginning of list of ProcessIds

Then you will get a RoundRobin approach.

WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560