Solution of the Dining Philosophers Problem using Shared Memory and Semaphores

Two versions of this program are included. One is written in C and the other in CPP. Both make use of the pthreads library to start a new process that shares memory with it's parent. They both also use POSIX unnamed semaphores.

Both programs require several support files written in C:

  1. msecond.c and msecond.h: Implements a function that returns the number of milliseconds (resolution is system dependent but is commonly 10 milliseconds) since it's first invocation.

  2. random_int.c and random_int.h: Implements a function that returns a random integer from an exponetial distribution with a specified mean. There is also a function to initialize the random number generator. Used the standard library functions random() and srandom().

For the C version you need:

  1. The source: philosopher.c.

  2. The C version of the Makefile.

For the C++ version you need:

  1. The source:

  2. The C++ version of the Makefile.