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:
2026-03-14 22:20:10 +00:00
parent 72145257de
commit 7c630ece54
2 changed files with 26 additions and 0 deletions

View File

@@ -32,6 +32,12 @@ struct waitqueue {
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_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 wakeup_queue(struct waitqueue *q);
extern void wakeup_one(struct waitqueue *q);

View File

@@ -32,6 +32,26 @@ void thread_wait_end(struct wait_item *waiter, struct waitqueue *q)
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)
{
unsigned long flags;