How to use TestAndSet() for solving the critical section problem?
- by Dan Mantyla
I'm studying for an exam and I'm having difficulty with a concept. This is the pseudo code I am given:
int mutex = 0;
do {
while (TestAndSet(&mutex));
// critical section
mutiex = 0;
// remainder section
} while (TRUE);
My instructor says that only two of the three necessary conditions (mutual exclusion, progress, and bounded waiting) are met with this code, but I don't understand which one isn't being met...??
How should the code be modified to support the missing condition to solve the critical region problem? Thanks in advance for any insight!