I'm new to OS, and I read a question on textbook today.
Instead of doing this:
bool AquireLock(int mutex)
{
while (mutex > 0); // do nothing until mutex == 0
mutex++;
return true;
}
This way requires lots of meaningless CPU cycle, is there a better way to implement this?