edit

edit
Last edited on
i am creating an application that simulates cpu scheduling algorithms
Then simulate it.
The events that you need to take into account are 'job_arrival' and 'job_finish'.

Mantain a buffer of the proccess that can be executed (because their arrival_time <= current_time). Those need to be sorted according with CpuBurst.
I will suggest you to use 'insertion_sort' as you will be working online.

Another approach.
Sort all the jobs by the CpuBurst. When you need the next to be executed, check that arrival_time <= current_time

Process temp[1]; //temporary struct for the sort An array of 1 element...
edit
Last edited on
edit
Last edited on
¿So you didn't do anything?
current_time starts in 0
_ A wild process appears
_ CPU uses execute. It's super effective.
_ The process fainted
Now current_time += time_taked_fighting with the process

In the time that the CPU was busy, new request were created. Those were enqueued.
Choose from that buffer the "shortest". Executed and repeat till the buffer is empty.

When you execute a process you'll update the variables (like WaitTime)


If you can't do it in paper then don't bother
edit
Last edited on
Topic archived. No new replies allowed.