More ideas for simulating the scheduling of processes.

If you want to try simulating a short job first scheduler (strictly optional!), you might proceed as follows:

Try creating three queues. The "before" queue will hold all of the processes before they enter the system. The "during" queue will hold processes between the time they enter the system and the time at which they are served. The "after" queue will hold processes after they have been served. The "before" and "after" queues can be FIFO queues (the kind that I defined in the example code that I shared with our class). The "during" queue should be a priority queue. The amount of a service that a process requires will determine its priority. A priority queue can be modeled with an array. The magic of a priority queue is that it gives us the process with the highest priority (the least service time) without having to completely sort the processes that are waiting for service. You will need to read a bit on the Web to learn more about how to build a priority queue.

You will have a variable whose value is a measure of the time that has elapsed during your simulation. You will have a loop that repeatedly moves processes from one queue to another until both the "before" and the "during" queues are empty. You will have to determine when a process should be moved from the "before" queue to the "during" queue, when a process should be moved from the "during" queue to the "after" queue, and when the program should increase the value of the elapsed time variable.

I have asked you to produce a simulation of a first-come, first-served scheduler. Anything else is optional. I would like to see progress on whatever variation of the project you have chosen by Wednesday. I expect everyone will still have more work to do on their projects.


Last modified: Tuesday, December 1, 2015, 7:28 AM