Simulation in Scratch of various Operating Systems scheduling algorithms
Created by Nick Cook
last edited Aug 06 2019 by Nick Cook
This a simulation that I use in my undergraduate module on Operating Systems. I use Scratch because it is easy to produce the animation, the logic of a given algorithm is clear in the code of the relevant scheduler sprite, and it is relatively easy to add new scheduler sprites to simulate different algorithms.
The simulation is shared on the Scratch site at: https://scratch.mit.edu/projects/322896616
Offline versions for Scratch 2 and 3 are attached.
Instructions, with further information, are give below.
Level: Advanced - for A level
Teaches: operating sytems scheduling alogorithms, which are part of the A level syllabus
Press the green flag to initialise the simulation. You can then choose which algorithm to simulate or pick the default. Currently, there are simulations of 4 algorithms: First Come First Served (fcfs), Shortest Job First (sjf), Shortest Remaining Time Next (srtn - preemptive sjf) and Round Robin (rr). There is a separate scheduler sprite for each algorithm, which is coded under the “when I receive tick …” message receipt block of the relevant sprite.
Press space bar to start the simulation. Random values are generated for the amount of work for each job, in simulated time units, and the arrival time of each job. You are given the opportunity to change these. For example, you could change them to use the same values to compare different algorithms with the same starting conditions.
The simulation shows: