ok, i need help with changing the state of a process. So far my struct Process has an integer which contains the priority and a pointer next which points to another process, and i need to add a state so that every time i call the function insert() it would change its state to READY and display it, and also every time i call the function remove() it should change its state to RUNNING. any help on doing this? is there an easy way?
this is some part of my header and class file
struct Process
{
int id;
Process *next;
};
void LL::insert(el_t NewNum)
{
if(rear == NULL)//CASE:1(if rear is null)
{
front = rear = new Process;
rear->id = NewNum;
}
else//CASE:2(if the list is not empty)
{
rear->next = new Process;
rear = rear->next;
rear->id = NewNum;
rear->next = NULL;
}
count++;
sort();
}
void LL::displayQueue()
{
if(isEmpty())
{
cout <<"queue is empty";
}
else
{
PCB *x = front;
while(x!= NULL)
{
cout << x->id << "\t";
x = x->next;
}
cout << endl;
}
}
void LL::remove(el_t& OldNum)
{
if(isEmpty())//CASE:1(if the list is empty)
{
cout <<"Cant remove from an empty list";
}
else//CASE:2(if the list is not empty)
{
PCB *second;
second = front->next;
delete front;
front = second;
}
count--;
}