Simulating scheduling algorithms is an excellent way to test and compare different algorithms
in various scenarios. It helps in choosing an appropriate algorithm both for an OS or large
scale systems. On such systems, the access patterns of resources (e.g, CPU, memory) by
users/processes, and the necessary system metrics (e.g., process turnaround time, CPU/mem-
ory usage) can be recorded for later analysis. Also, data from a real system can be used
as an input to simulate the processes/applications from a real system, and to test how the
system would perform with different scheduling algorithms. In this assignment, you will
create three different scheduler programs that each implement a different process
scheduling algorithm to simulate the scheduling of processes in a system.
You will not be doing scheduling of real processes, however your programs will determine the
sequence in which a certain number of `imaginary’ processes are to be executed.
This document constitutes the requirement specification for this assignment. You will be
assessed on your ability to both comprehend and comply with the requirements as specified
Late submissions: A late submission penalty of 10% of the total assignment marks per
day will apply. No submissions will be accepted after 22nd October 2021 (end of semester 2)
except in exceptional circumstances.
This assignment is worth 15% of the total marks for this unit.
3 About the `processes’
In this assignment, we will use a simplified model of a process, where each process:
1. has a pre-defined total service time, and
2. does not use I/O and can never be in a blocked state, and
3. will eventually run to completion and does not encounter any errors (e.g. segmentation
Each process should be represented within your program as a process control block (PCB)
instance defined as follows:
1 /∗ S p e c i a l enumerated data t ype f o r p r o c e s s s t a t e ∗/
2 t y p e d e f enum f
3 READY, RUNNING, EXIT
4 g p r o c e s s s t a t e t ;
6 /∗ C data s t r u c t u r e used as p r o c e s s c o n t r o l b l o c k . The s c h e d u l e r
7 ∗ s h o u l d c r e a t e one i n s t a n c e pe r r u n n i n g p r o c e s s i n the sys t em .
9 t y p e d e f s t r u c t f
10 cha r proc e s s name [ 1 1 ] ; // A s t r i n g t h a t i d e n t i f i e s the p r o c e s s
12 /∗ Times a r e measured i n s e c onds . ∗/
13 i n t ent ryTime ; // The t ime p r o c e s s e n t e r e d sys t em
14 i n t s e r v i c eTime ; // The t o t a l CPU t ime r e q u i r e d by the p r o c e s s
15 i n t r emainingTime ; // Remaining s e r v i c e t ime u n t i l c omp l e t i o n .
17 p r o c e s s s t a t e t s t a t e ; // c u r r e n t p r o c e s s s t a t e ( e . g . READY) .
18 g p c b t ;
As a PCB is essentially a container containing information about a process, using a struct
keeps all the information about a process neatly encapsulated and makes it easier to manage
from a coding perspective1
3.1 Important notes
PCBs should be used to hold the information about the current processes of the system
only. You MUST NOT:
• store the information of a process which has not yet arrived (i.e. has an arrival time in
the future), or
• has been terminated.
• modify the above struct denition to include additional process information, and
• also include additional states in the process state t enumerated type if it is useful for
your implementation of the tasks in Section 5.
3.2 How to `run’ a process
Our processes have state information, but no program code to be executed! Times are mea-
sured in seconds and represented as integers. Your scheduler should progress through each
second during the simulation and update the process states accordingly. The scheduling pro-
gram should instantly move and start working on the next second without any delay/wait after
it nishes updating the process states for the current second.