Hyperactive g_event thread
Jaakko Heinonen
jh at FreeBSD.org
Fri Oct 22 18:46:52 UTC 2010
On 2010-10-22, Ivan Voras wrote:
> Isn't this sequence:
>
> - mtx_unlock(&g_eventlock);
> wakeup(&g_wait_event);
> + mtx_unlock(&g_eventlock);
>
> too racy? It is possible, especially if something changes in scheduling
> or the wakeup() implementation, and on single-CPU machines, that the
> woken thread could run and then encounter the lock not yet released,
> leading to more lock waiting.
As far as I have understood this is the normal way to protect against
losing wakeups, no? wakeup(9) marks the sleeping process runnable and
removes it from the sleep queue but doesn't force a context switch
immediately. Thus increased lock contention would happen only if a
context switch happens between wakeup() and mtx_unlock(). I don't see
this a problem but please correct me if I am wrong.
--
Jaakko
More information about the freebsd-geom
mailing list