Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is the wakeup order for sleeping threads?

sleeping threads wakeup
0
Posted

What is the wakeup order for sleeping threads?

0

Raghu Angadi wrote: > A. Hirche wrote: > > > > Is it > > (a) the first thread in the queue (assuming there is an ordered list of > > waiting threads) > > (b) any thread (nondeterministic choice) > > (c) a thread chosen by some other scheme > > Threads are queued in priority order. > > So the thread with the maximum priority will get the mutex. > > If there more than one threads with max priority, then it is > implementation dependant. Not quite! Actually, POSIX places mutex (and condition variable) wakeup ordering requirements only when: 1. The implementation supports the _POSIX_THREAD_PRIORITY_SCHEDULING option. 2. The threads waiting are scheduled using the SCHED_FIFO or SCHED_RR policies defined by POSIX. If these conditions are true, then POSIX requires that threads be awakened in priority order. Multiple threads of identical priority must be awakened “first in first out”. The wakeup order for threads that don’t use SCHED_FIFO or SCHED_RR, (e.g., the default SCHED_OTHER on many UNI

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123