And "Operating System Concepts" Chapter VI of the seventh edition of the project: producer - consumer issues
Subject description:
Dining Philosophers Problem Description There are five philosophers, their lifestyle is alternately thinking and eating, n philosophers share a round table, to sit on the five chairs were around, there are five bowls on a round table and five chopsticks, n philosophers usually think, when hungry they tried to take its left and right chopsticks closest to him only when he got two chopsticks to eat, n meal is finished, put down the chopsticks and continue to think about.
As shown in FIG.
Numbers are 0-4. 0-3 philosopher left chopsticks number i, the right for the i + 1.
Philosopher 4 of 4 chopsticks left, to the right of zero. (Because it is a round-table thing)
Code:
Here ret should use int. . I forgot changed.
Renderings:
Problems encountered:
Solution: should be placed in the main function initialize
Solution: a low-level error. . . . Actually use the function name as variable names.