#Round Robin Simulation

4 messages · Page 1 of 1 (latest)

frail isle
#

Hello, I am trying to create a program that simulates a round robin process. When I input set values it gives me a reasonable output. However, when I try to create random values for the service and arrival times it gives me a bunch of 0's and negative numbers. The code for the set values is (https://pastebin.com/tYhsUULZ) and the one for random values is (https://pastebin.com/yRfAAW4e).

I created random times for the service and arrival times. (For the arrival times I created interarrival times and then added it to the previous process arrival time to get the actual arrival time). Then I tried to create a queue where if the arrival time for a process was less than the timer a new process would get added to the queue. Then if the remaining time on the process is greater than 1 it would peek the queue and increment the timer by the quantum, decrease the remaining time by the quantum, and remove + add the process to put it at the back of the queue. If the remaining was less than or equal to 1 it would increment the timer, set the remaining time to 0, make the end time for the process the value of the timer, and remove the process from the queue.

This is done in a loop while the queue isn't empty and the process is less than length so that all processes enter the queue. Am I going about the queue wrong or is it something else that it making the output for the random values to be 0's and negative numbers while the set values gives a reasonable output? (Could the change in length potentially affect it?)

runic anvilBOT
#

This post has been reserved for your question.

Hey @frail isle! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

runic anvilBOT
#

<@&765578700724371486>

Requested by WhoTao#3547