I am working on a problem where I am supposed to implement an example of the dining philosopher paradigm. Note: Yes this a homework assignment, before anyone asks.
I am not asking for a solution though. I am confused because this Philosopher
function that was supplied below by my teacher is theoretically supposed to work. wait
and signal
are the function used in C for OS system calls.
I have included them using:
/* Wait and Signal */
#include <signal.h>
#include <sys/wait.h>
struct semaphore
{
int count = 1;
struct PCB *Sem_Queue ;
};
struct semaphore Forks[5];
Philosopher()
{
i = getPID() ;
while (1)
{
think ();
wait (Forks[i]);
wait (Forks[(i+1) % 5]);
eat ();
signal (Forks[i]);
signal (Forks[(i + 1) % 5]);
}
}
However, when compiled I get the error:
Main.c:38:19: error: too few arguments to function call, expected 2, have 1
signal (Forks[i]);