//**************************************************************// // // // Program: Dining Philosopher Problem // // Filename: dine.cm // // Original author: Neil Bergmann // // Modification: Tracy Camp // // // // This program implements the dining philosopher problem. // // This version occasionally results in deadlock. // // // //**************************************************************// //**************************************************************// // GLOBAL DECLARATIONS // const int number= 5; //number of diners// const int true = 1; // logical true const int false= 0; // logical false const int none = -1; // indicates nobody has a fork semaphore fork[number]; //fork provides mutual exclusion on forks - only one diner can // //grab a fork at a time// int hasfork[number]; //hasfork keeps a record of which diner currently has a particular fork// int dinerseaten[number]; //records which diners have eaten so far// //YOU CAN ADD DECLARATIONS HERE// //**************************************************************// int left (int diner) //returns index of fork to the left of 'diner'// //DO NOT CHANGE THIS FUNCTION// { return diner; } //left// int right (int diner) //returns index of fork to the right of 'diner'// //DO NOT CHANGE THIS FUNCTION// { if (diner < number-1 ) return (diner+1); else return 0; //fork to right of last diner is #0// } //right// //**************************************************************// void initialize () //YOU CAN ADD ANY INITIALIZATIONS HERE// { int count; for (count=0; count