0

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?

user229044
  • 222,134
  • 40
  • 319
  • 330
Keith
  • 1

0 Answers0