Hey guys, I have a midterm coming up and I am confused on this one question. Any help would be greatly appreciated.

Two processes (P0, P1) are running at the same time. We want to preserve the critical section with two semaphores (S, Q) with initial value 1.

      P1                             P2
   wait(S)                         wait(Q)
   wait(Q)                         wait(S)
//Critical Section              //Critical Section
  signal(S)                       signal(Q)
  signal(Q)                       signal(S)

What is the problem with the solution above and how can you correct this?

The order that the processes are "waiting" may cause some issues. Look into deadlocks.

In some cases, mutex locks are preferable. Are you allowed to use those? You can simulate a mutex with semaphores, but it isn't simple.