2. Round-Robin Simulation 2.1. Problem Description We reviewed a Round-Robin strategy for effectively sharing processes on a single CPU. In the starting code, the number of initial processes was fixed and additional processes were added randomly. You are to enhance this program to read a series of instructions for the introduction of processes at specific launch times. The instruction format follows: AT
ADD where and are in milliseconds. Both are integers. The instructions will come in order of increasing . Do not assume that the first process will start at time 0. The last instruction will be simply DONE. Simulate the Operating System scheduling starting at simulation time 0 milliseconds. Use a time slice of 10 milliseconds. Before executing the next time slice, add any/all processes that should have started at or before the current time to the end of the active list of processes. For example: Instructions: AT ADD Process1 64 AT 12 ADD Process 2 35 AT 20 ADD Process3 47 AT 38 ADD Process4 16 DONE Execution trace: @00010 0:[] @00010 Added new Process {Process1: 64} @00020 1:[{Process1: 54}] Page 2 . . . . DONE @00020 Added new Process {Process2: 35} @00020 Added new Process Process3: 47} @00030 3:[{Process2: 35}, {Process 3: 47}, {Process1: 44}] @00040 3:[{Process3: 47}, {Process1: 44}, {Process2: 25}] @90940 Added new Process {Process4: 16} When all the processes have completed execution, print the number of time slices and the completion time (in milliseconds). Your output must include the names of all the team members. A sample set of commands is available in ProcessSequence1.txt. The output is shown below in Required Output. Your program will be tested with this input and several others so test it well. 2.2. Notes Start with the partially implemented code found with this assignment: CircularlyLinkedList.java Process.java Round Robin Simulation.java You will not need to modify CircularlyLinkedlist.java or Process.java. Turn in only your modified source file: AdvRoundRobinSimulation.java. Make sure your class is not in a package (that is, it is in the default package). 2.3. Required Main Class AdvRoundRobinSimulation 2.4. Required Input A series of user entered process instructions as described in the Problem Description. Read the input until the instruction DONE is seen. 2.5. Required Output For the instruction file Process Sequence1.txt, your output should look like the following (input is in GREEN). Round Robin Simulation - Team Member 1, Team Member 2, Team Member 3, ... AT 4 ADD P1 64 AT 12 ADD P2 35 AT 20 ADD P3 47 AT 38 ADD P4 16 AT 49 ADD P5 12 AT 50 ADD P6 81 AT 140 ADD P11 71 AT 142 ADD P12 24 AT 143 ADD P13 32 AT 157 ADD P14 9 AT 345 ADD P15 20 200010 0:[] 200010 Added new Process {P1: 64} @00020 1:[{P1: 54}] @00020 Added new Process {P2: 35) 200020 Added new Process {P3: 47} @00030 3:[{P2: 35}, {P3: 47}, {P1: 44}] 200040 3:[{P3: 47}, {P1: 44}, {P2: 25}] 200040 Added new Process {P4: 16} Page 3 200050 4:[{P1: 44}, {P2: 25}, {P4: 16}, {P3: 37}] 200050 Added new Process {P5: 12) @00050 Added new Process {P6: 81} 200060 6:[{P2: 25}, {P4: 16}, {P3: 37}, {P5: 12}, {P6: 81}, {P1: 34}] @00070 6:[{P4: 16}, {P3: 37}, {P5: 12}, {P6: 81}, {P1: 34}, {P2: 15}] Canada [{P3: 37: {P5: 12} {P6: 81}, {P1: 34}, {P2: 15}, {P4: 6}] 200098 6:{{P5: 12} {P6: 81}, {P1: 34}, {P2: 15}, {P4: 6}, {P3: 27}] 200100 6:[{P6: 81}, {P1: 34}, {P2: 15}, {P4: 6}, {P3: 27}, {P5: 2}] 200110 6:[{P1: 34}, {P2: 15}, {P4: 6}, {P3: 27}, {P5: 2}, {P6: 71}] 200120 6:[{P2: 15}, {P4: 6}, {P3: 27}, {P5: 2}, {P6: 71}, {P1: 24}} 200130 6:[{P4: 6}, {P3: 27}, {P5: 2}, {P6: 71}, {P1: 24}, {P2: 5} 200149 5:[{P3: 27}, {P5: 2}, {P6: 71}, {P1: 24}, {P2: 5}] 200140 Added new Process {P11: 71} 200150 6:[{P5: 2}, {P6: 71}, {P1: 24}, {P2: 5}, {P11: 71}, {P3: 17}] @00150 Added new Process {P12: 24} @00150 Added new Process (P13: 32) 200160 7:[{P6: 71}, {P1: 24}, {P2: 5}, {P11: 71}, {P3: 17}, {P12: 24}, {P13: 32}] 200160 Added new Process {P14: 9) @00170 8:[{P1: 24}, {P2: 5}, {P11: 71}, {P3: 17}, {P12: 24}, {P13: 32}, {P14: 9}, {P6: 61}] 200180 8:[{P2: 5}, {P11: 71}, {P3: 17}, {P12: 24}, {P13: 32}, {P14: 9}, {P6: 61}, {P1: 14}] @00190 7:[{P11: 71}, {P3: 17}, {P12: 24}, {P13: 32}, {P14: 9}, {P6: 61}, {P1: 14}] @00200 7:[{P3: 17}, {P12: 24}, {P13: 32}, {P14: 9}, {P6: 61}, {P1: 14}, {P11: 61}] @90210 7:[{P12: 24}, {P13: 32}, {P14: 9}, {P6: 61}, {P1: 14}, {P11: 61}, {P3: 7}] @00220 7:[{P13: 32}, {P14: 9}, {P6: 61}, {P1: 14}, {P11: 61}, {P3: 7}, {P12: 14}] @00230 7:[{P14: 9}, {P6: 61}, {P1: 14}, {P11: 61}, {P3: 7}, {P12: 14}, {P13: 22}] @00240 6:[{P6: 61}, {P1: 14}, {P11: 61}, {P3: 7}, {P12: 14}, {P13: 22}] 200250 6:[{P1: 14}, {P11: 61}, {P3: 7}, {P12: 14}, {P13: 22}, {P6: 51} @00260 6:[{P11: 61}, {P3: 7}, {P12: 14}, {P13: 22}, {P6: 51}, {P1: 4}] 200270 6:[{P3: 7}, {P12: 14}, {P13: 22}, {P6: 51}, {P1: 4}, {P11: 51}] 202288 5:{{P12: 14}, {P13: 22}, {P6: 51}, {P1: 4}, {P11: 51}} 200309 5: [{P6: 51}, {P1: 4}, {P11: 51), P12: 4}, {P13: 12}] 200310 5:[{P1: 4}, {P11: 51}, {P12: 4}, {P13: 12}, {P6: 41}] 200320 51}, {P12: 4}, {P13: 12}, {P6: 41}] 200330 4:[{P12: 4}, {P13: 12}, {P6: 41}, {P11: 41}] 200340 3:[{P13: 12}, {P6: 41}, {P11: 41}] 200350 3:[{P6: 41}, {P11: 41}, {P13: 2}] 200350 Added new Process {P15 20) 200368 4:[{P11: 41}, {P13: 2}, {P15: 20}, {P6: 31}] 200370 4:[{P13: 2}, {P15: 20}, {P6: 31}, {P11: 31}i 200380 3:[{P15: 20}, {P6: 31}, {P11: 31}] 200390 3:({P6: 31}, {P11: 31}, {P15: 1011 200400 3:[{P11: 31}, {P15: 10}, {P6: 21} 200410 3:[{P15: 10}, {P6: 21}, {P11: 21}] 200420 2:[{P6: 21}, {P11: 21}] 200430 2:[{P11: 21}, {P6: 11}] 200440 2:[{P6: 11}, {P11: 11}] 200450 2:[{P11: 11}, {P6: 1}] 200460 2:[{P6: 1}, {P11: 1}] 200470 1:[{P11: 1}] 200328 4: {{P11: Simulation ended at 00480. 11 Processes were completed in 47 time slices. Page 4 1 2 package linkedlists; public class RoundRobinSimulation { 4 private final static int NUM_PROCESSES_INIT = 10; private final static int MAX PROCESS_DRATION = 250; private final static int TIME_SLICE = 10; private final static double ADD_PROCESS_THRESHOLD = 0.03; private final static boolean VERBOSE_MODE = true; public static void main(String[] args) { CircularlyLinkedList processList = new CircularlyLinkedList(); int processNum = 1; int simulation Time = 0; int sliceCount = 0; for (int i = 0; i 0 ? d: 0; } 8 9 10 11 12 13 14 15 16 17 18 19 A201 21 22 23 public int execute(int slice) { duration -= slice; if (duration private static class Node { private E element; private Node next; public Node(e, Nodecs n) { element - next = n; ) public EgetElement() { 14 return element; } 16 ie public Nodest> getNext() { return next; } public void setNext (Node n) { next- } } private Nodecs tall: private int size: public CircularlyLinkedListd) { tail = null; size=; } public int length() { return size: } 37 38 39 4e 42 43 45 46 47 48 public boolean is Empty() { return size - } public Egetfirst if (isempty()) { return null; } return tall.getNext().getElement(); (.; } public EgetLasto{ if (isErpty()) { return null; } return tail.getElement(); } 57 public void rotatel) if (!isEmpty()) { tail = tail.getNext(); } } } be 61 63 65 66 67 68 69 public void addFirstE e) { if (isErpty()) { tail = new Nodee, null; tail.setNext(tail); } else { Nodese newest = new Nodesele, tail.getNext()); tail.setNext(newest); } size++; } public void addlast(e) { addFirstle); rotate(); } 71 72 73 74 25 76 77 78 79 Be 81 82 83 B4 B5 BE 87 88 89 public E renoveFirst() { 1f (isempty()) { return null; } Node head = tail.getNext(); 11 (length() - 1) { tail = null; } else { tati.setNext (head.getNext()); } size- return head.getElement(); } } A93 94 public String toString() { String result = length() + ":["; if (lisEmpty() { Node p = tail.getNext(); for (int count - @; count ADD where and are in milliseconds. Both are integers. The instructions will come in order of increasing . Do not assume that the first process will start at time 0. The last instruction will be simply DONE. Simulate the Operating System scheduling starting at simulation time 0 milliseconds. Use a time slice of 10 milliseconds. Before executing the next time slice, add any/all processes that should have started at or before the current time to the end of the active list of processes. For example: Instructions: AT ADD Process1 64 AT 12 ADD Process 2 35 AT 20 ADD Process3 47 AT 38 ADD Process4 16 DONE Execution trace: @00010 0:[] @00010 Added new Process {Process1: 64} @00020 1:[{Process1: 54}] Page 2 . . . . DONE @00020 Added new Process {Process2: 35} @00020 Added new Process Process3: 47} @00030 3:[{Process2: 35}, {Process 3: 47}, {Process1: 44}] @00040 3:[{Process3: 47}, {Process1: 44}, {Process2: 25}] @90940 Added new Process {Process4: 16} When all the processes have completed execution, print the number of time slices and the completion time (in milliseconds). Your output must include the names of all the team members. A sample set of commands is available in ProcessSequence1.txt. The output is shown below in Required Output. Your program will be tested with this input and several others so test it well. 2.2. Notes Start with the partially implemented code found with this assignment: CircularlyLinkedList.java Process.java Round Robin Simulation.java You will not need to modify CircularlyLinkedlist.java or Process.java. Turn in only your modified source file: AdvRoundRobinSimulation.java. Make sure your class is not in a package (that is, it is in the default package). 2.3. Required Main Class AdvRoundRobinSimulation 2.4. Required Input A series of user entered process instructions as described in the Problem Description. Read the input until the instruction DONE is seen. 2.5. Required Output For the instruction file Process Sequence1.txt, your output should look like the following (input is in GREEN). Round Robin Simulation - Team Member 1, Team Member 2, Team Member 3, ... AT 4 ADD P1 64 AT 12 ADD P2 35 AT 20 ADD P3 47 AT 38 ADD P4 16 AT 49 ADD P5 12 AT 50 ADD P6 81 AT 140 ADD P11 71 AT 142 ADD P12 24 AT 143 ADD P13 32 AT 157 ADD P14 9 AT 345 ADD P15 20 200010 0:[] 200010 Added new Process {P1: 64} @00020 1:[{P1: 54}] @00020 Added new Process {P2: 35) 200020 Added new Process {P3: 47} @00030 3:[{P2: 35}, {P3: 47}, {P1: 44}] 200040 3:[{P3: 47}, {P1: 44}, {P2: 25}] 200040 Added new Process {P4: 16} Page 3 200050 4:[{P1: 44}, {P2: 25}, {P4: 16}, {P3: 37}] 200050 Added new Process {P5: 12) @00050 Added new Process {P6: 81} 200060 6:[{P2: 25}, {P4: 16}, {P3: 37}, {P5: 12}, {P6: 81}, {P1: 34}] @00070 6:[{P4: 16}, {P3: 37}, {P5: 12}, {P6: 81}, {P1: 34}, {P2: 15}] Canada [{P3: 37: {P5: 12} {P6: 81}, {P1: 34}, {P2: 15}, {P4: 6}] 200098 6:{{P5: 12} {P6: 81}, {P1: 34}, {P2: 15}, {P4: 6}, {P3: 27}] 200100 6:[{P6: 81}, {P1: 34}, {P2: 15}, {P4: 6}, {P3: 27}, {P5: 2}] 200110 6:[{P1: 34}, {P2: 15}, {P4: 6}, {P3: 27}, {P5: 2}, {P6: 71}] 200120 6:[{P2: 15}, {P4: 6}, {P3: 27}, {P5: 2}, {P6: 71}, {P1: 24}} 200130 6:[{P4: 6}, {P3: 27}, {P5: 2}, {P6: 71}, {P1: 24}, {P2: 5} 200149 5:[{P3: 27}, {P5: 2}, {P6: 71}, {P1: 24}, {P2: 5}] 200140 Added new Process {P11: 71} 200150 6:[{P5: 2}, {P6: 71}, {P1: 24}, {P2: 5}, {P11: 71}, {P3: 17}] @00150 Added new Process {P12: 24} @00150 Added new Process (P13: 32) 200160 7:[{P6: 71}, {P1: 24}, {P2: 5}, {P11: 71}, {P3: 17}, {P12: 24}, {P13: 32}] 200160 Added new Process {P14: 9) @00170 8:[{P1: 24}, {P2: 5}, {P11: 71}, {P3: 17}, {P12: 24}, {P13: 32}, {P14: 9}, {P6: 61}] 200180 8:[{P2: 5}, {P11: 71}, {P3: 17}, {P12: 24}, {P13: 32}, {P14: 9}, {P6: 61}, {P1: 14}] @00190 7:[{P11: 71}, {P3: 17}, {P12: 24}, {P13: 32}, {P14: 9}, {P6: 61}, {P1: 14}] @00200 7:[{P3: 17}, {P12: 24}, {P13: 32}, {P14: 9}, {P6: 61}, {P1: 14}, {P11: 61}] @90210 7:[{P12: 24}, {P13: 32}, {P14: 9}, {P6: 61}, {P1: 14}, {P11: 61}, {P3: 7}] @00220 7:[{P13: 32}, {P14: 9}, {P6: 61}, {P1: 14}, {P11: 61}, {P3: 7}, {P12: 14}] @00230 7:[{P14: 9}, {P6: 61}, {P1: 14}, {P11: 61}, {P3: 7}, {P12: 14}, {P13: 22}] @00240 6:[{P6: 61}, {P1: 14}, {P11: 61}, {P3: 7}, {P12: 14}, {P13: 22}] 200250 6:[{P1: 14}, {P11: 61}, {P3: 7}, {P12: 14}, {P13: 22}, {P6: 51} @00260 6:[{P11: 61}, {P3: 7}, {P12: 14}, {P13: 22}, {P6: 51}, {P1: 4}] 200270 6:[{P3: 7}, {P12: 14}, {P13: 22}, {P6: 51}, {P1: 4}, {P11: 51}] 202288 5:{{P12: 14}, {P13: 22}, {P6: 51}, {P1: 4}, {P11: 51}} 200309 5: [{P6: 51}, {P1: 4}, {P11: 51), P12: 4}, {P13: 12}] 200310 5:[{P1: 4}, {P11: 51}, {P12: 4}, {P13: 12}, {P6: 41}] 200320 51}, {P12: 4}, {P13: 12}, {P6: 41}] 200330 4:[{P12: 4}, {P13: 12}, {P6: 41}, {P11: 41}] 200340 3:[{P13: 12}, {P6: 41}, {P11: 41}] 200350 3:[{P6: 41}, {P11: 41}, {P13: 2}] 200350 Added new Process {P15 20) 200368 4:[{P11: 41}, {P13: 2}, {P15: 20}, {P6: 31}] 200370 4:[{P13: 2}, {P15: 20}, {P6: 31}, {P11: 31}i 200380 3:[{P15: 20}, {P6: 31}, {P11: 31}] 200390 3:({P6: 31}, {P11: 31}, {P15: 1011 200400 3:[{P11: 31}, {P15: 10}, {P6: 21} 200410 3:[{P15: 10}, {P6: 21}, {P11: 21}] 200420 2:[{P6: 21}, {P11: 21}] 200430 2:[{P11: 21}, {P6: 11}] 200440 2:[{P6: 11}, {P11: 11}] 200450 2:[{P11: 11}, {P6: 1}] 200460 2:[{P6: 1}, {P11: 1}] 200470 1:[{P11: 1}] 200328 4: {{P11: Simulation ended at 00480. 11 Processes were completed in 47 time slices. Page 4 1 2 package linkedlists; public class RoundRobinSimulation { 4 private final static int NUM_PROCESSES_INIT = 10; private final static int MAX PROCESS_DRATION = 250; private final static int TIME_SLICE = 10; private final static double ADD_PROCESS_THRESHOLD = 0.03; private final static boolean VERBOSE_MODE = true; public static void main(String[] args) { CircularlyLinkedList processList = new CircularlyLinkedList(); int processNum = 1; int simulation Time = 0; int sliceCount = 0; for (int i = 0; i 0 ? d: 0; } 8 9 10 11 12 13 14 15 16 17 18 19 A201 21 22 23 public int execute(int slice) { duration -= slice; if (duration private static class Node { private E element; private Node next; public Node(e, Nodecs n) { element - next = n; ) public EgetElement() { 14 return element; } 16 ie public Nodest> getNext() { return next; } public void setNext (Node n) { next- } } private Nodecs tall: private int size: public CircularlyLinkedListd) { tail = null; size=; } public int length() { return size: } 37 38 39 4e 42 43 45 46 47 48 public boolean is Empty() { return size - } public Egetfirst if (isempty()) { return null; } return tall.getNext().getElement(); (.; } public EgetLasto{ if (isErpty()) { return null; } return tail.getElement(); } 57 public void rotatel) if (!isEmpty()) { tail = tail.getNext(); } } } be 61 63 65 66 67 68 69 public void addFirstE e) { if (isErpty()) { tail = new Nodee, null; tail.setNext(tail); } else { Nodese newest = new Nodesele, tail.getNext()); tail.setNext(newest); } size++; } public void addlast(e) { addFirstle); rotate(); } 71 72 73 74 25 76 77 78 79 Be 81 82 83 B4 B5 BE 87 88 89 public E renoveFirst() { 1f (isempty()) { return null; } Node head = tail.getNext(); 11 (length() - 1) { tail = null; } else { tati.setNext (head.getNext()); } size- return head.getElement(); } } A93 94 public String toString() { String result = length() + ":["; if (lisEmpty() { Node p = tail.getNext(); for (int count - @; count