refactored pwait race generation in fifo_xxx

The race generating function pwait() in fifo_xxx wasn't
working properly and often got stuck in a deadlock.
Latter mutexes, or those in other functions, were shared
which contributed to the deadlock issue.

The code has been refactored and simplified.
Now each of the pwait instances can be uniquely defined.
And deadlocks are no longer an issue.