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 multi-core computing system consisting of four (4) homogeneous CPUs: 1) FCFS (First-Come-First-Served) scheduling. 2) RR (Round Robin) scheduling with time quantum q=3 milliseconds, q=10 milliseconds, and q=45 milliseconds, respectively. 3) Three-level feedback-queue (FBQ) preemptive scheduling employing queue Q0(RR, quantum q=8 milliseconds), queue Q1(RR, quantum q=20 milliseconds), and queue Q2(FCFS) as shown in Figure 5.9 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 Q1 if its original queue was Q0 or into Q2 if its original queue was Q1(b) a process finishing its I/O bursts should be promoted by placing it into Q0(c) 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: 1) What is the average waiting time? 2) What is the average turnaround time? 3) 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 400% if all 4 CPUs are running, 300% if only 3 CPUs are running, 200% for 2 CPUs, 100% for only 1 CPU, and 0% if no CPU is running.)4) 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 I/O.)5) 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 fcfs.c, for the RR scheduler in a file named rr.c, and for the FBQ scheduler in a file named fbq.c. When the programs run, they should print the results to the standard output (stdout). For this project, you are provided with two helper files (sch-helpers.c and sch helpers.h), which include C functions for loading data from a CPU load file, for sorting processes, and for linked-list based scheduling queue operations.
sch-helpers.c:
/**
* Description: Some helper functions to be used for CSE3221 "scheduler" project
*/
/* Some hints to use these helper functions in this project */
/*
Step 1: You should include the header file in your main scheduler code:
#include "sch-helpers.h"
Step 2: you should declare a global array in your own fcfs.c to hold info for all processes:
process processes[MAX_PROCESSES+1]; // a large structure array to hold all processes read from data file
int numberOfProcesses=0; // total number of processes
Step 3: you can call function readProcess() to read all data from stdio and sort the processes array ascending by arrival time:
...
while (status=readProcess(&processes[numberOfProcesses])){
if(status==1) numberOfProcesses ++;
}// it reads pid, arrival_time, bursts to one element of the above struct array
...
qsort(processes, numberOfProcesses, sizeof(process), compareByArrival);
...
Step 4: You may consider to use the following linked-list based Queue management functions to impelement all scheduling queues (Ready Q and Device Q) for your scheduler:
process_node *createProcessNode(process *);
void initializeProcessQueue(process_queue *);
void enqueueProcess(process_queue *, process *);
void dequeueProcess(process_queue *);
Step 5: After you are done, you can submit your fcfs.c as well as sch-helpers.h sch-helpers.c to the system.
Your code should compile as:
$$ gcc -o fcfs fcfs.c sch-helpers.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 "sch-helpers.h"/* include a header file for function defintions and others */
/** Error management functions **/
/* print error message to stderr and terminate abnormally */
void error(char *msg){
fprintf(stderr,"%s
", msg);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!