Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i want the program to be Writen in C++ General Instructions In this assignment,

ID: 3594835 • Letter: I

Question

i want the program to be Writen in C++

General Instructions

In this assignment, you will create a PCB (Process Control Block) class which holds the information of a process such as id, arrival time, start time, end time and burst time(job time). All possible class variables should be initialized in the constructor by reading the input file. Hence number of PCB objects is determined by the input file.

Create a Scheduler class. It should enqueue the PCB objects into a STL Queue based on the arrival time and dequeue a PCB object whenever the CPU is free. Calculate whether CPU is free based on the allocation time + burst time of the previous PCB object. Assume CPU is free for the initial case.

To Summarize the steps

1. Open input data source (Use of stringstream will bag you a bonus point)

2. Initialize clock (to zero)

3. Increment clock counter

4. Enqueue process (if any)

5. Check CPU availability. If available, dequeue one of the available process to the CPU based on the shortest burst time(job time)

6. If process in in CPU is done, free the CPU.

7. Repeat 3-6 till PCB queue and CPU are both empty

8. Print the following summary for each process.

i. Arrival Time (Time at which the process arrives in the ready queue.)

ii. Completion Time (Time at which process completes its execution)

iii. Burst Time(Time required by a process for CPU execution)

iv. Turn Around Time (Turn Around Time = Completion Time - Arrival Time + 1)

v. Waiting Time (Waiting Time = Turn Around Time - Burst Time)

Programming concepts that are expected in the solution:

Sample Input

ID                                    Arrival                          Burst

#1

1

8

#2

3

2

#3

4

6

#4

8

2

#5

12

1

#1

1

8

#2

3

2

#3

4

6

#4

8

2

#5

12

1

Explanation / Answer

Code:

#include<iostream>
#include<cstring.h>
#include<conio.h>

class ProccessBlockList
{

public:
int burstTime;
int ProcessID;
string state;

public:

ProccessBlockList()
{
state="Ready";
burstTime=5;
}
void addProcess(int PID)
{
cout<<"Enter Burst Time ";
cin>>burstTime;
ProcessID=PID;
}
void updateProcessBlock(string S)
{
state=S;
}

void executeProcess(int timeSlot)
{
cout<<"***Load the PCB of Process <<ProcessID<<"*********"<<endl;
state="Running";
cout<<"Process ID= "<< ProcessID<<endl;
cout<<"State "<<state<<endl;
cout<<"Burstime "<<burstTime<<endl;
if((burstTime-timeSlot)>0)
{
cout<<"Remaining Time to finish "<<(burstTime-timeSlot)<<endl;
cout<<"***Save the PCB of Process "<<ProcessID<<"*******"<<endl;
}
else
{
state="Dead";
cout<<"****Process"<<ProcessID<<"Has finished and exited*********"<<endl;
}
}
};

void main()
{

int hover=0;
int timeSlot=1;
ProccessBlockList plist[10];

for(int k=0;k<5;k++)
{
plist[k].addProcess((k+1));
hover +=plist[k].burstTime;
}
while(hover != 0)
{
for(int i=0; i<5; i++)
{
if(plist[i].burstTime > 0)
{
if(plist[i].burstTime > timeSlot)
{
plist[i].updateProcessBlock("Ready");
plist[i].executeProcess(timeSlot);
plist[i].burstTime -= timeSlot;
hover -= timeSlot;
}
else
{
plist[i].updateProcessBlock("Ready");
plist[i].executeProcess(plist[i].burstTime);
hover -= plist[i].burstTime;
plist[i].burstTime = 0;
}
}
}
}
getch();
}