Ignore:
File:
1 edited

Legend:

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

    rdf58e44 r1d432f9  
    127127/** Interrupt sleeping thread.
    128128 *
    129  * This routine attempts to interrupt a thread from its sleep in
    130  * a waitqueue. If the thread is not found sleeping, no action
    131  * is taken.
    132  *
    133  * The threads_lock must be already held and interrupts must be
    134  * disabled upon calling this function.
     129 * This routine attempts to interrupt a thread from its sleep in a waitqueue.
     130 * If the thread is not found sleeping, no action is taken.
    135131 *
    136132 * @param thread Thread to be interrupted.
     
    142138        DEADLOCK_PROBE_INIT(p_wqlock);
    143139       
    144         /*
    145          * The thread is quaranteed to exist because
    146          * threads_lock is held.
    147          */
     140        irq_spinlock_lock(&threads_lock, true);
     141        if (!thread_exists(thread))
     142                goto out;
    148143       
    149144grab_locks:
     
    155150                        /*
    156151                         * The sleep cannot be interrupted.
     152                         *
    157153                         */
    158154                        irq_spinlock_unlock(&thread->lock, false);
    159                         return;
     155                        goto out;
    160156                }
    161157               
    162158                if (!irq_spinlock_trylock(&wq->lock)) {
    163                         /* Avoid deadlock */
    164159                        irq_spinlock_unlock(&thread->lock, false);
    165160                        DEADLOCK_PROBE(p_wqlock, DEADLOCK_THRESHOLD);
     161                        /* Avoid deadlock */
    166162                        goto grab_locks;
    167163                }
     
    177173                irq_spinlock_unlock(&wq->lock, false);
    178174        }
    179        
    180175        irq_spinlock_unlock(&thread->lock, false);
    181176       
    182177        if (do_wakeup)
    183178                thread_ready(thread);
     179       
     180out:
     181        irq_spinlock_unlock(&threads_lock, true);
    184182}
    185183
     
    372370                 * If the thread was already interrupted,
    373371                 * don't go to sleep at all.
     372                 *
    374373                 */
    375374                if (THREAD->interrupted) {
     
    382381                 * Set context that will be restored if the sleep
    383382                 * of this thread is ever interrupted.
     383                 *
    384384                 */
    385385                THREAD->sleep_interruptible = true;
Note: See TracChangeset for help on using the changeset viewer.