I have to make a Round Robin scheduler for a class. I initially created 3 List<int> lists to represent the process ids, their arrival time and their processing time. I sorted them by their arrival times. The processes are being assigned a fixed quantum (I’ve hard-coded that as 4) and now I want to apply RR on them and display the sequence order of each process & their remaining time in a textBox on a form.
I found one approach here, but it’s in java:
https://stackoverflow.com/questions/7544452/round-robin-cpu-scheduling-java-threads
I tried converting my three lists into object lists as shown in the link but basically, so far I’ve succeeded in creating a list of objects that represent processes. In each object, the processname, arrivaltime, bursttime are stored. This is represented by a class called PCB.
Now I’ve created a list in which to add a number of processes:
public List<pcb> list = new List<pcb>(); // In place of ArrayList used in the
// example code in the link.
//For loop runs in which above 3 parameters are assigned values & then they're
// added to list:
PCB pcb = new PCB(processname1, arrivaltime1, bursttime1);
list.Add(pcb);
But how do I search through each value of the list in order to find an item and manipulate it? Say I want to access bursttime of processname="P1" and decrement it by 4?
Is this the wrong data structure for it in C#?
If you prefer iterating through the list: