Domanda

It would seem to be a no-brainer, but just wanted to check if this is guaranteed (on Linux). Is the thread precluded from scheduling until the wait condition is satisfied? Or will the thread get scheduled, figure out it's still waiting and yield() again, wasting resources?

The reason I am asking is, if I have X threads running, and some threads are blocked for whatever reason, will the blocked threads get in the way of runnable threads (assuming they are the same priority)?

È stato utile?

Soluzione

Yes, they wait without consuming any CPU resources. Only spinlocks do a busy wait.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top