sched: wait: implement wakeup_n, waitqueue_empty
This commit is contained in:
18
sched/wait.c
18
sched/wait.c
@@ -69,6 +69,24 @@ void wakeup_queue(struct waitqueue *q)
|
||||
spin_unlock_irqrestore(&q->wq_lock, flags);
|
||||
}
|
||||
|
||||
void wakeup_n(struct waitqueue *q, size_t nr_waiters)
|
||||
{
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&q->wq_lock, &flags);
|
||||
struct queue_entry *ent = queue_pop_front(&q->wq_waiters);
|
||||
while (ent && nr_waiters > 0) {
|
||||
struct wait_item *waiter
|
||||
= QUEUE_CONTAINER(struct wait_item, w_entry, ent);
|
||||
struct thread *thr = waiter->w_thread;
|
||||
thread_awaken(thr);
|
||||
|
||||
ent = queue_pop_front(&q->wq_waiters);
|
||||
nr_waiters--;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&q->wq_lock, flags);
|
||||
}
|
||||
|
||||
void wakeup_one(struct waitqueue *q)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
Reference in New Issue
Block a user