CAS Community   >   Resources   >  

Screenshot_2019-08-01_at_11.32.23
Operating Systems Scheduling Simulation

Simulation in Scratch of various Operating Systems scheduling algorithms

Nick Cook

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

Instructions

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:

  • A yellow processor box
  • Jobs represented by the running girl, which can be in not ready, ready, running and terminated states (a running job will move to the processor)
  • A not ready/terminated area for jobs that have not arrived into the system or that have terminated
  • The following variables:
    • algorithm - the algorithm being simulated
    • time - the elapsed simulated time
    • tick - the tick interval - unit of simulated time that passes at each tick
    • mean work - the mean work for jobs (average of work of each job)
    • running job - the identifier of each job
    • mean turnaround - the mean turnaround time for jobs in the system calculated at the end of the simulation (this is good metric for comparison of scheduling in batch systems and is used to compare the behaviour algoirthms - round robin will have the worst mean turnaround time because it is designed for interactive systems optimised for response time)
    • jobs - a slider to control the number of jobs in the system
    • speed - a slider to control the speed of the animation
    • quantum - the quantum for a CPU burst (only shown for the round robin algorithm)
  • And the following lists:
    • work - the amount of work for each job
    • arrival - the arrival time of each job
    • start - the start time of each job
    • remaining - the remaining time of each job (the work currently left to complete)
    • finish - the finish time of each job
    • turnaround - the turnaround time of each job (finish time - arrival time)
Downloaded 215 times.

Download

This resource has attached files: to access these files, please tick the box below to assent to the license terms
License: The resources on CAS website are under Creative Commons Attribution-Share Alike 3.0 licence unless otherwise specified by the resource creators.

You must confirm that you have read and agree the licence's ToS before you can download the attachments of this resource.

I have read the licence agreement of this resource and agree to abide by its terms and conditions.

Feedback and Comments


Available when logged in (join via the front page, for free):
  • View 0 comments on this resource.
  • View resource history, links to related resources.
  • Leave feedback for the author(s), or help by editing the resource.
Categories: