I need help how to change the state of a process using link list queue. any help is appreciated. This is part of my code.
what i need is that every time i insert a process im suppose to change its state to READY, and every time i need to remove i need to change its state to RUNNING. i need help implementing that to my functions.
This is part of my header file
typedef int el_t;
struct Process
{
el_t id; // id in each node
Process *next;// link to the next process
string state;
};
and this is part of my other code,
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++;
}
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)
{
Process *second;
second = front->next;
delete front;
front = second;
}
count--;
}
void LL::displayQueue()
{
if(isEmpty())
{
cout <<"queue is empty";
}
else
{
Process *x = front;
while(x!= NULL)
{
cout << x->id << "\t";
x = x->next;
}
cout << endl;
}
}