Question: Assignment Details There are two source files you need to complete. parta.c contains the scheduling code, and is testing using the unit test file test
Assignment Details
There are two source files you need to complete. parta.c contains the scheduling code, and is testing using the unit test file testacpp partamain.c contains the commandline interface, and should be done after parta.c is complete.
parta.c
Debugging
Try to use printf debugging, where you insert print statements at strategic locations. You can also use the debugger in VSCode. Click the "bug" icon in the "Testing" tab.
The functions in this file are tested by teststestacpp
Init
struct pcb initprocsint bursts, int blen;
The first function you should complete is initprocs. This function takes an array of CPU bursts, and returns an array of PCBs The PCBs should be created in the heap, and each object contains the PID, burstleft, and the total wait this process has experienced so far.
Scheduling
double fcfsavgwaitint bursts, int blen;
double rravgwaitint bursts, int blen, int quantum;
You are given an array of CPU bursts and the time quantum for roundrobin Create the array of PCBs using initprocs, and then start scheduling. You can keep track of each process' wait time by looking at the PCB array's wait variable.
Firstcomefirstserve scheduling will start from index and run each process until completion.
Roundrobin scheduling will take an additional parameter quantum Each process will run until it runs out of CPU burst or the time quantum whichever comes first
Assume that all processes arrived that the same time, but in the order listed in bursts.
Next Process
int fcfsnextint current, struct pcb procs, int plen;
int rrnextint current, struct pcb procs, int plen;
A helper function called next is provided to make it easier to develop the scheduler. These functions return the next process to run. For example, let's say there are processes total. If the current process is P under FCFS the next process would be P If the current process is P this would be the end, so return
Under round robin, if the current process is P next is p; if current is P next is P If all the processes are complete burstleft is then return
partamain.c
You are to process the commandline arguments. The first argument is the algorithm to use: fcfs or rr If using fcfs then remaining values are the array of CPU bursts. If using rr the immediate next value is the time quantum, and the CPU bursts follow that.
After identifying the algorithm to use, print the current setting and then print the average wait time up to decimal points For example, if we want fcfs with processes:
$ buildsrcpartamain fcfs
Using FCFS
Accepted P: Burst
Accepted P: Burst
Accepted P: Burst
Average wait time:
If we want roundrobin with time quantum with processes:
$ buildsrcpartamain rr
Using RR
Accepted P: Burst
Accepted P: Burst
Accepted P: Burst
If the commandline arguments are not correctly provided, print a usage message and exit with status immediately. For example:
$ buildsrcpartamain rr
Usage:
partamain fcfsrr BURSTS
$ buildsrcpartamain firstcomefirstserve
Usage:
partamain fcfsrr BURSTS
You may use any function from stdlib.h stdio.h string.h or ctype.h For example, strcmp or atoi can be used.
To test this part, run the following command in the terminal:
runsh testa
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
