Ignore:
File:
1 edited

Legend:

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

    r96c30c8 rb59318e  
    190190        if (do_wakeup)
    191191                thread_ready(thread);
     192}
     193
     194/** Interrupt the first thread sleeping in the wait queue.
     195 *
     196 * Note that the caller somehow needs to know that the thread to be interrupted
     197 * is sleeping interruptibly.
     198 *
     199 * @param wq Pointer to wait queue.
     200 *
     201 */
     202void waitq_unsleep(waitq_t *wq)
     203{
     204        irq_spinlock_lock(&wq->lock, true);
     205
     206        if (!list_empty(&wq->sleepers)) {
     207                thread_t *thread = list_get_instance(list_first(&wq->sleepers),
     208                    thread_t, wq_link);
     209
     210                irq_spinlock_lock(&thread->lock, false);
     211
     212                assert(thread->sleep_interruptible);
     213
     214                if ((thread->timeout_pending) &&
     215                    (timeout_unregister(&thread->sleep_timeout)))
     216                        thread->timeout_pending = false;
     217
     218                list_remove(&thread->wq_link);
     219                thread->saved_context = thread->sleep_interruption_context;
     220                thread->sleep_queue = NULL;
     221
     222                irq_spinlock_unlock(&thread->lock, false);
     223                thread_ready(thread);
     224        }
     225
     226        irq_spinlock_unlock(&wq->lock, true);
    192227}
    193228
Note: See TracChangeset for help on using the changeset viewer.