How to use Parallel Semaphores for Dining Philosophers Problem I am in an intro to OS class and we are learning about mutual exclusion and semaphores. One classical problem we learned about was the dining philosophers problem. My professor touched on the different cases using simple semaphores (i.e asking the last philosopher to grab the right fork before the left while the others grab right first) however, these still violates the concurrency requirement.
He explained that these types of problems begin to show the importance of advanced synchronization and how we need more but he didn't go into details because that subject belongs to the actual Operating Systems course.
I am curious as to how you could implement AND semaphores to solve the dining philosophers problem. I did some research and could not find any great resources showing implementations using AND or monitors.
Could someone go into some detail or point me to an article/textbook that does?
Assume we have 4 processes p[0], p[1],...,p[3] and 4 mutexes m[0],m[1],...m[3]. Now in order to solve the dining philosophers problem, we only need to make one of the philosopher (one of the processes) to take the folk (one of the mutexes) in reverse direction than the other philosophers. Note that by doing this, we are trying to avoid deadlock.

So in practice, we need to make all processes to follow certain implementation, except one.
All processes (philosophers) should follow this implementation:
while(1)
{
   down(m[(i+1) % 4]);
   down(m[i]);

   'critical section' 

   up(m[i]);
   up(m[(i+1)%4]);
}

except one process should follow this:
while(1)
{
   down(m[i]);
   down(m[(i+1) % 4]);

   'critical section' 

   up(m[i]);
   up(m[(i+1)%4]);
}


Note by down we mean taking the folks and by up we mean releasing the folks, and note how both implementations differ. For example, we made one of the philosopher to take the fort (down) in reverse order than the others.
I hope this could help.