I am working on the dining philosophers problem, and I am attempting to create a way to keep track of the shared recourse (the forks). So my thinking is to create an array of semaphores, and that way when i have to fork off i can keep track of the philosophers number and his fork for eating by utilizing the index in the array which would ideally contain the recourse.
So my question is, is this possible? Everything i have attempted has resulted in an error such as:
char ** sems[5];
sems[0] = struct sembuf a[1] = {{0, 1, 0}};
sems[1] = struct sembuf b[1]
sems[2] = struct sembuf c[1].... and so forth
however this is obviously the incorrect way to do this. can someone help point me in the right direction? .