ESE333 Project3
ESE333 Project3
Round-Robin Scheduling
Project 3
1 Introduction
In this assignment you are to implement a round-robin scheduling algorithm with one queue
on top of a custom simulation model. The assignment is divided into 3 main sections:
2 Overview
The simulation model comes with a few structs that you need to understand:
• computer
• core
• process
• node
computer: a struct that simulates a computer with 4 cores and the time using a single
value increment.
core: a struct that simulates a core that takes one process at a time, counts how long a
process has been on the core for the current quantum, and a busy signal indicating if the
core has a running process or not.
process: a struct simulating a process that has an ID, the time it arrives, and remaining
time which indicates how long that process needs to run on a core to finish, and I/O (either
0 or 1 values) which indicates an I/O event has happened and this process has to be taken
away from the core – resetting the I/O value (i.e. setting it to 0) then placing it to the back
of the linked list queue, and running this process again when its turn has come. In part 3
I/O will be used.
There are a few functions, some will need modifications, and some are there to help you:
1
• read file: This function handles reading and parsing input of processes from a text file.
Your first part of the assignment is to add code in that function to store the input
into an upcoming process queue structure. There are two queues in this assignment,
one where the scheduling algorithm processes, and the other for “future” processes
that will arrive in future. In the first part, you are to add all parsed processes to the
“future” queue in the same order of reading. You can assume processes will come in
ascending order of arrival time.
• run one step This function is to not be modified for any reason. This function incre-
ments the computer’s time by one millisecond and decides on each core, whether to
continue to run the current process, or the quantum is used up and should switch to
another process.
• run one step p3: This function is similar to the one above, but it generates I/O inter-
rupts with a probability at each millisecond, upon which the current process should be
switched out, and a new one comes in.
• remove proc: This function is a helper function that removes a process from a core,
and either discards it if its service time decreases to 0, or puts it to the tail of the
queue otherwise.
• sched proc: This function schedules a process to one of the cores which you do give
the ID of the core as a parameter (with the process too).
• demo: This function is purely a very basic demonstration of the functions model and
how to use. It adds 4 processes, and runs steps then removes a process when it finishes.
Your code for part 2 (i.e. scheduling algorithm) is to be inside a while loop that keeps
running till all processes are complete, many processes will take multiple quantam to
finish.
To summarize, a text file where each line is a process ID name, arrival time, and service
time will be parsed and one process struct per process should be created and stored in a
“upcoming queue”. As simulation runs and time proceeds, processes are to be added to the
round-robin queue to be processed when the their arrival times come (i.e. you can schedule
a process only upon its arrival time).
• Process ID
• service time
• arrival time
2
Therefore, your structure is to store process ID, service time, and arrival time. To refer to
the order and how it is parsed, please refer to function read file() which handles parsing
file for you. Your task is to create process structs and store information for each process in
an “upcoming processes queue”.
Note: You can assume that the input file will have ascending order of arrival times (i.e.
no need to sort your “upcoming processes queue”.