I'm trying to simulate the Dining Philosophers problem but I'm having trouble visualising it. When the thread moves from Waiting() to Eating() to Thinking() it changes a variable called state to represent this. However in my main thread it never sees the state variable change. It calls a return function for state when drawing to change the colour of the philosopher.
Any help with this?
Here is some code: State Change
void Philosopher::Eat()
{
state_ = EATING;
Sleep(500);
}
Return function
Philosopher::_state Philosopher::ReturnState()
{
return state_;
}
Call of return function
Philosopher::_state current_state_;
current_state_ = philosopher_[i].ReturnState();
switch (current_state_)
{
case Philosopher::PICKING:
{
glColor3f(1, 0, 0);
break;
}
case Philosopher::EATING:
{
glColor3f(0, 1, 0);
break;
}
case Philosopher::THINKING:
{
glColor3f(0, 0, 1);
break;
}
}