sched: add wait begin/end functions that don't change thread state
these functions can be used when waiting on multiple queues at once, to prevent the thread state from being changed unexpectedly while initialising a set of wait items.
This commit is contained in:
@@ -32,6 +32,12 @@ struct waitqueue {
|
|||||||
extern void wait_item_init(struct wait_item *item, struct thread *thr);
|
extern void wait_item_init(struct wait_item *item, struct thread *thr);
|
||||||
extern void thread_wait_begin(struct wait_item *waiter, struct waitqueue *q);
|
extern void thread_wait_begin(struct wait_item *waiter, struct waitqueue *q);
|
||||||
extern void thread_wait_end(struct wait_item *waiter, struct waitqueue *q);
|
extern void thread_wait_end(struct wait_item *waiter, struct waitqueue *q);
|
||||||
|
extern void thread_wait_begin_nosleep(
|
||||||
|
struct wait_item *waiter,
|
||||||
|
struct waitqueue *q);
|
||||||
|
extern void thread_wait_end_nosleep(
|
||||||
|
struct wait_item *waiter,
|
||||||
|
struct waitqueue *q);
|
||||||
extern void wait_on_queue(struct waitqueue *q);
|
extern void wait_on_queue(struct waitqueue *q);
|
||||||
extern void wakeup_queue(struct waitqueue *q);
|
extern void wakeup_queue(struct waitqueue *q);
|
||||||
extern void wakeup_one(struct waitqueue *q);
|
extern void wakeup_one(struct waitqueue *q);
|
||||||
|
|||||||
20
sched/wait.c
20
sched/wait.c
@@ -32,6 +32,26 @@ void thread_wait_end(struct wait_item *waiter, struct waitqueue *q)
|
|||||||
spin_unlock_irqrestore(&q->wq_lock, flags);
|
spin_unlock_irqrestore(&q->wq_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void thread_wait_begin_nosleep(struct wait_item *waiter, struct waitqueue *q)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
spin_lock_irqsave(&q->wq_lock, &flags);
|
||||||
|
|
||||||
|
queue_push_back(&q->wq_waiters, &waiter->w_entry);
|
||||||
|
|
||||||
|
spin_unlock_irqrestore(&q->wq_lock, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void thread_wait_end_nosleep(struct wait_item *waiter, struct waitqueue *q)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
spin_lock_irqsave(&q->wq_lock, &flags);
|
||||||
|
|
||||||
|
queue_delete(&q->wq_waiters, &waiter->w_entry);
|
||||||
|
|
||||||
|
spin_unlock_irqrestore(&q->wq_lock, flags);
|
||||||
|
}
|
||||||
|
|
||||||
void wakeup_queue(struct waitqueue *q)
|
void wakeup_queue(struct waitqueue *q)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|||||||
Reference in New Issue
Block a user