Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2314 → Rev 2315

/branches/rcu/kernel/generic/src/synch/waitq.c
383,13 → 383,10
* Besides its 'normal' wakeup operation, it attempts to unregister possible
* timeout.
*
* @param wq Pointer to wait queue.
* @param all If this is WAKEUP_ALL, all sleeping threads will be woken up and
* missed count will be zeroed. WAKEUP_FIRST wakes up just one thread or
* increments the missed count. WAKEUP_ALL_INC_MISSED wakes up all sleeping threads
* or increments missed_wakeups if there aren't any
* @param wq Pointer to wait queue.
* @param mode Wakeup mode.
*/
void waitq_wakeup(waitq_t *wq, int all)
void waitq_wakeup(waitq_t *wq, wakeup_mode_t mode)
{
ipl_t ipl;
 
396,10 → 393,10
ipl = interrupts_disable();
spinlock_lock(&wq->lock);
 
_waitq_wakeup_unsafe(wq, all);
_waitq_wakeup_unsafe(wq, mode);
 
spinlock_unlock(&wq->lock);
interrupts_restore(ipl);
spinlock_unlock(&wq->lock);
interrupts_restore(ipl);
}
 
/** Internal SMP- and IRQ-unsafe version of waitq_wakeup()
407,25 → 404,27
* This is the internal SMP- and IRQ-unsafe version of waitq_wakeup(). It
* assumes wq->lock is already locked and interrupts are already disabled.
*
* @param wq Pointer to wait queue.
* @param all If this is WAKEUP_ALL, all sleeping threads will be woken up and
* missed count will be zeroed. WAKEUP_FIRST wakes up just one thread or
* increments the missed count. WAKEUP_ALL_INC_MISSED wakes up all sleeping threads
* or increments missed_wakeups if there aren't any
* @param wq Pointer to wait queue.
* @param mode If mode is WAKEUP_FIRST, then the longest waiting thread,
* if any, is woken up. If mode is WAKEUP_ALL, then all
* waiting threads, if any, are woken up. If there are no
* waiting threads to be woken up, the missed wakeup is
* recorded in the wait queue.
*/
void _waitq_wakeup_unsafe(waitq_t *wq, int all)
void _waitq_wakeup_unsafe(waitq_t *wq, wakeup_mode_t mode)
{
thread_t *t;
count_t count = 0;
 
loop:
if (list_empty(&wq->head)) {
if (all == WAKEUP_ALL)
wq->missed_wakeups = 0;
else
wq->missed_wakeups++;
wq->missed_wakeups++;
if (count && mode == WAKEUP_ALL)
wq->missed_wakeups--;
return;
}
loop:
 
count++;
t = list_get_instance(wq->head.next, thread_t, wq_link);
/*
453,10 → 452,8
spinlock_unlock(&t->lock);
 
thread_ready(t);
if (list_empty(&wq->head)) {
return;
}
if (all != WAKEUP_FIRST)
 
if (mode == WAKEUP_ALL)
goto loop;
}