You are required to create a CPU Scheduler Simulator written in Python to schedule the provided dataset (the spreadsheet below) according to the four Scheduling Algorithms discussed in Week 2 tutorial activities.

The spreadsheet your Python Scripts must read is here. [attached xlsx]
When simulating the Round Robin algorithm, you must use Quantum = 3 TUs. RR is also subject to an overhead of 1 TU each time a context switch occurs, the same as explained in Tutorial 2 and illustrated in Lecture 5.

Algorithms:

  1. Priority Scheduling. PRI
  2. Round Robin Scheduling. RR

Fallback algorithms
As illustrated in the tutorial, there can be situations where it is not clear which process should be next to use the CPU. For example, if two processes arrive at the same time having the same priority when scheduling based on priority. For those situations, a fallback algorithm must be chosen. FIFO and SJF are both good as a fallback and both could be considered good choices, but in order to keep all submissions under the same parameters, let’s agree that:

  1. If by any chance when scheduling Priority two or more processes are ready to be selected, the scheduler must fall back to FIFO.
  2. If by any chance when scheduling Round Robin two or more processes are ready to be selected, the scheduler must fall back to SJF.

Resources you should refer to:

  1. The Dinosaur’s book, if possible.
  2. Week 2’s Lecture handouts, especially Lecture 5.
  3. Week 2’s Tutorial, especially the CPU Scheduling section.

Guidelines:
• The output of your simulator must be similar to the one we have been seeing in the Week 2 Tutorial.

This is an example of how the output of your scripts should look like:

Time Unit 1: PID 1 executes. 5 instructions left. Q=3.
PID 2 wait=1.

Time Unit 2: PID 1 executes. 4 instructions left. Q=2.
PID 2 wait=2. PID 3 wait=1.

Time Unit 3: PID 1 executes. 3 instructions left. Q=1.
PID 2 wait=3. PID 3 wait=2.

Time Unit 4: PID 1 executes. 2 instructions left. Q=0.
PID 2 wait=4. PID 3 wait=3.

Time Unit 5: Context switch. PID 2 wait=5.
PID 3 wait=4. PID 1 wait=1.

issuing python filename.py.

These are the questions the assessor will have in mind when assessing your submission:

  1. Does the CPU scheduler generate the expected output for each algorithm for a given set of test data?
  2. Does it look like the students submitted an authentic implementation?
  3. Does it work when I run it?

Sample Solution

This question has been answered.

Get Answer