How to use TestAndSet() for solving the critical section problem?
Posted
by Dan Mantyla
on Stack Overflow
See other posts from Stack Overflow
or by Dan Mantyla
Published on 2010-04-06T23:57:33Z
Indexed on
2010/04/07
0:03 UTC
Read the original article
Hit count: 196
test-and-set
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!
© Stack Overflow or respective owner