Fix another interesting bug. td_threadq is shared by the LWKT scheduler,
authorMatthew Dillon <dillon@dragonflybsd.org>
Sat, 10 Dec 2005 18:50:36 +0000 (18:50 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Sat, 10 Dec 2005 18:50:36 +0000 (18:50 +0000)
commit6330a558dca5b05584e8ee96251193d6bb242ae4
treebcabe8be7def8453f9ebfd9a91d7474e5001d55a
parent355ca5076a68e2080d17a4a1bf6dc172c7f04db7
Fix another interesting bug.  td_threadq is shared by the LWKT scheduler,
tsleep, and port-blocking code.  Because of this separate flags exist to
indicate which queue the thread currently resides on and careful sanity
checks were added to prevent corruption.

The thread scheduler will not enqueue a thread that is sitting on one of
these other queues.  This commit fixes a bug where the preemption code
would still preemptively switch into the thread even when the enqueue fails,
causing an assertion to be hit in tsleep().

This just goes to show that asserting on supposedly impossible conditions is
a good idea :-).

Reported-by: Stefan Krueger <skrueger@meinberlikomm.de>
sys/kern/lwkt_thread.c