homework 6 Version 0 |
|
👤 Author: by 1065486204qqcom 2017-11-16 13:10:41 |
This solution imposes the restriction that a philosopher may pick up her chopsticks only if both of them are available.To code this solution, we need to distinguish among three states in which we may find a philosopher.So, we introduce a data structure:
enum{thinking, hungry, eating}state[5]; Philosopher i can set the variable state[i] = eating only if her two neighbors are not eating:(state[(i+4)%5] != eating) and (state[(i+1)%5] != eating).
We also need to declare condition self[5]; wh