I am working on a project and part of the instruction goes like this:
"The whole system allows up to 10 processes currently stay in memory, only one of them is running on the CPU, while the others are in either the Ready Queue or blocked in the Disk queue. Each process has its PCB"
I have been able to create 10 processes and they are running fine. I'm trying to write the code for the Ready and Disk queue and I'm running into a few difficulties. Below is what I came up with. I tried writing two functions for the ready and disk queue but it wasn't working so I decided to write the code in the main function. Any suggestions on how to write the ready and disk queues (functions)?
struct PCB
{
int PID;
string process_state;
int progCount;
};
//Selecting process states
for (int i = 0; i < 10; i++)
{
infile >> processPCB.PID;
infile >> processPCB.process_state;
if (process_state == newprocess)
{
readyQueue.EnQueue(PID);
}
else if ( process_state == running)
{
diskQueue.EnQueue(PID);
}
else if (process_state == ready)
{
diskQueue.EnQueue(PID);
}
else if (process_state == waiting)
{
diskQueue.DeQueue(PID)
readyQueue.EnQueue(PID);
}
else
process_state == terminated;
}
void blockedDiskQueue(queue &Que, int pid)
{
}
void readyQueue(queue &Que, int pid)
{
}