Question: The CPU Scheduler is a key component of any multiprogramming operating system ( OS ) kernel. It is important to understand the details of the
The CPU Scheduler is a key component of any multiprogramming operating system OS kernel. It is important to understand the details of the CPU scheduling in order to fully comprehend the dynamic behavior of the operating systems. In this project, you are asked to write some C programs to simulate the following three CPU scheduling algorithms for a multicore computing system consisting of four homogeneous CPUs: FCFS FirstComeFirstServed scheduling. RR Round Robin scheduling with time quantum q milliseconds, q milliseconds, and q milliseconds, respectively. Threelevel feedbackqueue FBQ preemptive scheduling employing queue QRR quantum q milliseconds queue QRR quantum q milliseconds and queue QFCFS as shown in Figure in the textbook. Read the corresponding text for details about this scheduling algorithm and include in your implementation the following: a a process exceeding its time quantum should be preempted and demoted by placing it into Q if its original queue was Q or into Q if its original queue was Qb a process finishing its IO bursts should be promoted by placing it into Qc a process preempted for servicing a higher priority queue should be placed in the beginning of its original ready queue When you implement your simulations, if two or more processes are identical in terms of scheduling criterion, you should give precedence to the process that has the smallest process ID PID number. Based on the given static CPU workload in the CPULoad.dat text file your programs must perform the necessary simulations and answer all the following questions for each of the above CPU schedulers: What is the average waiting time? What is the average turnaround time? When does the CPU finish all these processes? What is the average CPU utilization by this time point? Note that at any time instance, CPU utilization is if all CPUs are running, if only CPUs are running, for CPUs, for only CPU, and if no CPU is running. How many context switches occur in total during the execution? Note that you should count as context switches only the cases where a process is preempted during its CPU burst, and not the cases where a process terminates or just finishes its current CPU bursts and goes to IO Which process is the last one to finish? In this project, you need to write three C programs to implement simulations with the above CPU schedulers. For the FCFS scheduler, put your program in a file named fcfsc for the RR scheduler in a file named rrc and for the FBQ scheduler in a file named fbqc When the programs run, they should print the results to the standard output stdout For this project, you are provided with two helper files schhelpers.c and sch helpers.h which include C functions for loading data from a CPU load file, for sorting processes, and for linkedlist based scheduling queue operations.
schhelpers.c:
Description: Some helper functions to be used for CSE "scheduler" project
Some hints to use these helper functions in this project
Step : You should include the header file in your main scheduler code:
#include schhelpers.h
Step : you should declare a global array in your own fcfsc to hold info for all processes:
process processesMAXPROCESSES; a large structure array to hold all processes read from data file
int numberOfProcesses; total number of processes
Step : you can call function readProcess to read all data from stdio and sort the processes array ascending by arrival time:
while statusreadProcess&processesnumberOfProcesses
ifstatus numberOfProcesses ;
it reads pid, arrivaltime, bursts to one element of the above struct array
qsortprocesses numberOfProcesses, sizeofprocess compareByArrival;
Step : You may consider to use the following linkedlist based Queue management functions to impelement all scheduling queues Ready Q and Device Q for your scheduler:
processnode createProcessNodeprocess ;
void initializeProcessQueueprocessqueue ;
void enqueueProcessprocessqueue process ;
void dequeueProcessprocessqueue ;
Step : After you are done, you can submit your fcfsc as well as schhelpers.h schhelpers.c to the system.
Your code should compile as:
$$ gcc o fcfs fcfsc schhelpers.c
In this case you can redirect all CPU load data to stdio when you run your FCFS schedule:
$$ fcfs CPULoad.dat OR $$ cat CPULoad.dat fcfs
#include
#include
#include
#include
#include
#include schhelpers.h include a header file for function defintions and others
Error management functions
print error message to stderr and terminate abnormally
void errorchar msg
fprintfstderrs
msg;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
