Fix two bugs in the LWKT token code.
authorMatthew Dillon <dillon@dragonflybsd.org>
Sun, 19 Jun 2005 21:50:50 +0000 (21:50 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Sun, 19 Jun 2005 21:50:50 +0000 (21:50 +0000)
commit9a35dbc3068e9253de7acedb1beb898753971684
tree43b04730d972a623a1c4d32da18a5ac2eaff41ad
parentca0b96cb70e74f2c264468bba42a5b9dfeb1972a
Fix two bugs in the LWKT token code.

(1) When releasing a token reference we cannot give away the token to
    another cpu if we are still holding it via a another reference.   This
    can cause recursive token references to silently fail when the inner
    reference is released.  It is unclear where such references exist and
    a temporary printf has been added to identify occurances.

(2) When obtaining a token reference if the underlying token was not owned
    by the current cpu we spun to gain ownership, but then failed to check
    whether the token was being held by a preempted thread.

    This can result in a preempting thread holding a token also being held
    by an underyling thread.  Theoretically, this case can only
    occur if the preempted thread was is the process of obtaining the
    token in question since otherwise (by definition) our cpu will already
    own the token.  On return the preempted thread will check and obtain
    ownership.  However, the situation is complex enough that we really
    need to check unconditionally.
sys/kern/lwkt_token.c
sys/sys/thread2.h