In 1965, Dijkstra posed and solved a synchronization problem he called thedining philosophers problem. ........ The problem can be stated quite simplyas follows. Five philosophers are seated around a circular table. Each philosopher has a plate of spaghetti. The spaghetti is so slippery that a philosopher needs two forks to eat it. Between each pair of plates is one fork. The life of a philosopher consists of alternate periods of eating and thinking. When a philosopher gets hungry, she tries to acquire her left and rightfork, one at a time, in either order If successful in acquiring two forks, she eats for a while, then puts down the forks and continues to think Thekey question is:.. Can you write a program for each philosopher that does what IT Is Supposed to Do And Never Gets Stuck? --From
}:: Else:: Philosophy (1);}:: else:: philosophy (0) ;:::::::::::::: "% D% S / N", I, "is thinking") ;:: for (t = 0; t <= rand () 1000; t ) ;:: State [i = "hungry" ;:: Printf ("% D% S / N", I, "is Hungry") ;:: for (t = 0; t <= rand () 10000; t ) ;:: for (; i! = j;): : {FSEEK (F, 0L, 0) ;:: j = getc (f);}:: state [i = "eating" ;:: Printf ("% D% s / n", i, "is eat" );: J = (j 1)% N:: fseek (f, 0l, 0) ;:: PUTC (J, f) ;::}::