/* Philosopher process, input is the philosopher number. */ #include "dining.h" void philosopher(int me) { char *s; int i = 1; for ( ; ; ++i) { /* forever */ pick_up(me); s = i == 1 ? "st" : i == 2 ? "nd" : i == 3 ? "rd" : "th"; printf("Philosopher %d eating for the %d%s time\n", me, i, s); sleep(Busy_Eating); put_down(me); printf("Philosopher %d thinking\n", me); sleep(Busy_Thinking); } }