Round Robin Scheduling - operating-system

I have a question here about round-robin and I was wondering if this answer is correct(it is the dr.'s answer).
We are supposed to get the average turnaround time of the processes who all come at same time which came in order as in the picture, it uses round robin with quantum of 5 seconds
Given answer was like that
But I think there are some extra counted time in there so my answer is like that
(26+27+12+16+30) / 5 = 22.2
I was wondering which one is correct, in my answer I tracked each process got its finish time and subtracted from start time which is 0 in this case.

According to the question given, the correct answer is 22.2

Related

Shortest Process Next Scheduling Algorithm

I am wondering which answer is correct?For answer 1, when P5 is finish executing, then we compared about P3,P6 and P4 ,if we compare them according to the arrival time then P3 will execute first. So,my question is about do we need to follow the arrival time? Which answer is correct? Thanks.
This is the question image
The first answer is correct.
A case could be made that both are correct, but the first is "more correct." The tiebreaker for this scheduling algorithm should be the arrival time. Your goal is to minimize the process wait time, and it makes more sense to first run the process that has been waiting longer.
Algorithms like this will often use a priority queue, which would sort the elements from shortest burst time to longest burst time. Queues use FIFO (first in, first out), which means if there are two elements with the same burst time, the one that was added first would be selected first.

AnyLogic "triggered by rate" implementation

Anybody has a reference for how AnyLogic implements it's rate per day? Specifically, my agent is at different locations (based on time of day) throughout the day. If there are 10 triggers a day, do they happen randomly for each agent throughout the day, or only at the beginning of a day (when agent is at home), etc.?
Thank you, Amy! Your explanation was very helpful.
The rate follows the Poisson distribution. If you divide 1/rate, you will get an inter-arrival time that follows the exponential.
As this is random, you may not actually get 10 a day - you may get 9 one day and 11 the next. If you want to get exactly 10 in a day, you need to think about writing your own code to make that happen. That might be something like generating 10 dynamic events randomly sampled times that all trigger a transition in their action code (that would not be exponential between events).

How does CPU know how much time a process take to complete?

I studying various CPU scheduling algorithm in OS, I was asked this question once I was not able to answer it. Can anyone explain me?
OS can compute the total needed time for each task, by means of first calculating its CPI (cycles per instruction). There is a weighted average CPI for each job. I hope this answers the question. But if you are talking about burst time then there is a default value to those unknown processes.

Is the Rate in the source block a fixed rate?

I have a simple source to sink model and I am merely altering the "Rate" to 6 per hour. I would expect a fixed 6 agents to be generated each hour, but it seems like in the first hour from 0 to 60min, only 3 agents are generated. Similarly in the time 60-120min, only 5 agents were generated.
Is there a warm up period in Anylogic or something like this that explains what is happening?
Another alternative is to just use the interarrival time with a fixed time. This will give you the same results as Felipe's answer, but with one less object, as you will not need the event.
A few important items to note on this approach:
Instead of 6.0, using a parameter would be better. You could call this parameter dArrivalsPerHour. This would make your source block easier to read in the future, and give you some better flexibility. Your interarrival time would be 1.0 / dArrivalsPerHour.
Make sure you divide by at least (1) double. If you did 1/6, java would actually return 0! This is because in Java two integers divided by each other returns an integer, so java just truncates the decimal. If you use a parameter, just set its type to double. Usually to be extra careful against anyone accidentally changing my parameter type to integer in the future, I would still go ahead and use a 1.0.
AnyLogic does not have an arrival at time zero in this approach. The first arrival would be at 0.166 hours. If you want an arrival at time zero, followed by this pattern (it would still be 6 per hour, just shifting when it starts), then you have a couple of options. First, you can use Felipe's approach and set the first occurrence time to zero. An alternative would be to could call an inject On Startup OR after you have finished any initialization code your model has.
Happy Modeling!
The source block doesn't produce exactly 6 agents per hour, it produces agents using a poisson distribution with mean 6 per hour (lambda=6). So the number of agents per hour you get will be random. But the reason why you always get 3 in the first hour and 5 in the second hour is that you have a fixed seed:
You can find that option clicking on your simulation experiment under the randomness tab. If you change to random seed it will produce different agents per hour instead of always 3 and 5.
To produce EXACTLY 6 per hours you need to use an event. But first create a source that generates agents through injection:
And the event running 6 times per hour, adding 1 agent to the source:

Detect when 2 recurring (time triggered) scripts will sync [Theoretical]

This is a somewhat theoretical question. I have 2 CRON jobs that run in a staggered interval, one every 13 minutes, and the other every 15 minutes.
I know it's very easy to stop them running at the same time etc with locks/stops.
However it got me thinking in a theoretical sense, how the synchronisations in time; when they both run at the same minute could be visualised.
So far it's actually a pretty interesting logic, as it's a case of converting the 13 minutes and 15 minutes into similar 24 based hour formats, and then detecting if any of them match. This bit isn't too hard, and the basic logic I have sort of got in this jsFiddle (Very ugly and janky/long way around, but it sort of works): http://jsfiddle.net/wigster/kdo5bwk9/
I can't quite visualise how/when these sync/simultaneousness' will occur though (I know they WILL occur, I just don't know if that's day's/weeks/months apart etc).
This may possibly be a question I should ask on https://math.stackexchange.com/ but StackOverflow is my frequent, so I'll try here first.
As I said, this is not for any real world application, simply a maths logic that has intrigued me today.
TL:DR 2 "Things" running at 13 minutes and 15 minutes. At first it may seem simple, numbers that are divisible by both 13 and 15. Eg, we know they will both run at 9:30 eventually. But HOW OFTEN / regularly will the 13 min cycle hit 9:30 at the same time the 15 minute cycle hits 9:30 as it's likely to be ahead/behind most of the time.
#MrWigster