Changeset 497bd656 in mainline


Ignore:
Timestamp:
2012-11-16T14:49:21Z (11 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9fe9d296
Parents:
4f5e1c7c
Message:

Fix: averted a possible deadlock in condvar_wait_timeout() (eg when a thread has been interrupted and calls the function concurrently with another thread contending the mutex). Locking discipline: lock the mutex before the waitq.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/condvar.c

    r4f5e1c7c r497bd656  
    9191
    9292        ipl = waitq_sleep_prepare(&cv->wq);
     93        /* Unlock only after the waitq is locked so we don't miss a wakeup. */
    9394        mutex_unlock(mtx);
    9495
     
    9697        rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, flags);
    9798
     99        waitq_sleep_finish(&cv->wq, rc, ipl);
     100        /* Lock only after releasing the waitq to avoid a possible deadlock. */
    98101        mutex_lock(mtx);
    99         waitq_sleep_finish(&cv->wq, rc, ipl);
    100102
    101103        return rc;
     
    128130        ipl = waitq_sleep_prepare(&cv->wq);
    129131
     132        /* Unlock only after the waitq is locked so we don't miss a wakeup. */
    130133        spinlock_unlock(lock);
    131134
     
    134137
    135138        waitq_sleep_finish(&cv->wq, rc, ipl);
    136        
     139        /* Lock only after releasing the waitq to avoid a possible deadlock. */
    137140        spinlock_lock(lock);
    138141       
Note: See TracChangeset for help on using the changeset viewer.