Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 6c4a56f in mainline


Ignore:
Timestamp:
2009-08-21T07:03:12Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
057d21a
Parents:
2e151ab0
Message:

Support for waitq_unsleep().

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/synch/waitq.h

    r2e151ab0 r6c4a56f  
    7676extern void _waitq_wakeup_unsafe(waitq_t *, wakeup_mode_t);
    7777extern void waitq_interrupt_sleep(struct thread *);
     78extern void waitq_unsleep(waitq_t *);
    7879
    7980#endif
  • kernel/generic/src/synch/waitq.c

    r2e151ab0 r6c4a56f  
    171171out:
    172172        spinlock_unlock(&threads_lock);
     173        interrupts_restore(ipl);
     174}
     175
     176/** Interrupt the first thread sleeping in the wait queue.
     177 *
     178 * Note that the caller somehow needs to know that the thread to be interrupted
     179 * is sleeping interruptibly.
     180 *
     181 * @param wq            Pointer to wait queue.
     182 */
     183void waitq_unsleep(waitq_t *wq)
     184{
     185        ipl_t ipl;
     186
     187        ipl = interrupts_disable();
     188        spinlock_lock(&wq->lock);
     189
     190        if (!list_empty(&wq->head)) {
     191                thread_t *t;
     192               
     193                t = list_get_instance(wq->head.next, thread_t, wq_link);
     194                spinlock_lock(&t->lock);
     195                ASSERT(t->sleep_interruptible);
     196                if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))
     197                        t->timeout_pending = false;
     198                list_remove(&t->wq_link);
     199                t->saved_context = t->sleep_interruption_context;
     200                t->sleep_queue = NULL;
     201                spinlock_unlock(&t->lock);
     202                thread_ready(t);
     203        }
     204
     205        spinlock_unlock(&wq->lock);
    173206        interrupts_restore(ipl);
    174207}
Note: See TracChangeset for help on using the changeset viewer.