Question
Detailed steps for this session: Define a very basic PCB structure: struct PCB {int ProcId; int ProcPR, int CPUburst; int Reg[8]; int queueEnterClock, waitingTime; /*
Detailed steps for this session:
Define a very basic PCB structure: struct PCB {int ProcId; int ProcPR, int CPUburst; int Reg[8]; int queueEnterClock, waitingTime; /* other info */ struct PCB *next;}
Define a very basic CPU consisting of 8 integer registers: int CPUreg[8] = {0};
Initialize your linked list: struct PCB *Head=NULL; struct PCB *Tail=NULL;
Initialize your other data: int CLOCK=0; int Total_waiting_time=0; int Total_turnaround_time=0; int Total_job=0;
Open the input file
For each input line,
read a line consisting of three integers: Process Id, Process Priority, CPU Burst time.
dynamically create a struct PCB pointed by PCB,
save the given data into correponding fields of PCB,
set all PCB->Reg[8] to the Process ID, set PCB->queueEnterClock and PCB->waitingTime to 0, then
insert this PCB at the end of the link list.
Close input file
Print your name, the name of scheduling algorithm, and the input file name, as mentioned before.
------------------ The above steps will be the same for the next session too -----------------------
Now implement a FIFO_Scheduling() function and call it to print the order of completed processes.
This function simply removes the PCB from the head of the linked list and performs the followings until the linked list is empty: Do context-switching:
copy PCB->Reg[8] into CPUreg[8],
suppose some work is done on CPU (e.g, increment each CPUreg by one),
copy CPUreg[8] into PCB->Reg[8]
Data collection for performance metrics
PCB->waitingTime = PCB->waitingTime + CLOCK - PCB->queueEnterClock;
Total_waiting_time = Total_waiting_time + PCB->waitingTime ;
CLOCK = CLOCK + PCB->CPUburst;
Total_turnaround_time = Total_turnaround_time + CLOCK;
Total_job = Total_job + 1;
Free PCB. Since there is no more CPUburst or I/O burst, this process is terminated here! Otherwise, it will be put in a ready or waiting queue.
Finally, print the perfromance metrics mentioned before:
Total_waiting_time / Total_job,
Total_turnaround_time / Total_job,
Total_job / CLOCK
For each input file, copy/paste your screen output into a textfile (say output1.txt)
input1.txt:
1 3 5 2 3 7 3 1 6 4 5 4In this session, you will set up your account to implement necessary linked s functions for FIFO CP scheduling and perfom the very basie steps in conxt-swncfeIn the next session, you will extend this program to implement other three basie CP scheduling algorithms (namely, SUF, PR, and RR with a given quantum. To keep it simle, we assume each process has a single CPU barst without any LO burst and that all processes arrive at the same time in a given order. The order of processes will be given in a simple input file. Each line in the input file consists of three integer numhers: Process Id, Process Priority, CPU Burst time (ms). Download inputl txt as a sample input file. Your program ill take the name of the sche ling a gonthm, Ielated parameters 'if any, and an input ile name on command line. In genera ere how your p gram should be executed: proe -ale PRIR -quantum [intege In this session, you will just run it as ut tinput rile name. txt prog -alg FIFO-input inputi.tt For the gven input file, the output of your progam will be as follows Student Nane: Your naTe Enput rile Name inputl.txt cPU Scheduling Ale FIFO Proces 1 is conpleted at S m Proces 2 is conpleted at 12 Proces 3 is conpleted at 18 ms Proces 4 is conpleted at 22 ms Average Haiting ti- 8.75 m4(35/4) Average Turnaround time 14.25 ms (S7/4) Throughput e.18 jobs per ms (4/22) In this session, you will set up your account to implement necessary linked s functions for FIFO CP scheduling and perfom the very basie steps in conxt-swncfeIn the next session, you will extend this program to implement other three basie CP scheduling algorithms (namely, SUF, PR, and RR with a given quantum. To keep it simle, we assume each process has a single CPU barst without any LO burst and that all processes arrive at the same time in a given order. The order of processes will be given in a simple input file. Each line in the input file consists of three integer numhers: Process Id, Process Priority, CPU Burst time (ms). Download inputl txt as a sample input file. Your program ill take the name of the sche ling a gonthm, Ielated parameters 'if any, and an input ile name on command line. In genera ere how your p gram should be executed: proe -ale PRIR -quantum [intege In this session, you will just run it as ut tinput rile name. txt prog -alg FIFO-input inputi.tt For the gven input file, the output of your progam will be as follows Student Nane: Your naTe Enput rile Name inputl.txt cPU Scheduling Ale FIFO Proces 1 is conpleted at S m Proces 2 is conpleted at 12 Proces 3 is conpleted at 18 ms Proces 4 is conpleted at 22 ms Average Haiting ti- 8.75 m4(35/4) Average Turnaround time 14.25 ms (S7/4) Throughput e.18 jobs per ms (4/22)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started