Discussion Section for November 1, 2012: Dining Philosophers!

In Discussion Section

In ds8, you will solve a dining philosopher problem. Basically, A fork is placed between each pair of adjacent philosophers. Each philosopher must alternately think and eat. However, a philosopher can only eat when he has both his left and right forks.

In this miniMP, we are going to solve the problem with the following approach; A philosopher can only eat whenever both forks are available. There are three functions that you need to implement pickup and putdown.

To help you with this miniMP, there are a couple of structures that are provided. The first is the global_state variable in dphil.h which describes the number of philosophers, the state of each philosophers and also provide you with the necessary synchronization variables. You may also find the variable id in phil_t to be useful too.

Compiling and Running

To compile and run your shell, run the following commands from a Terminal on a Linux machine:

$ make
$ ./dphil num_philosopher