|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "kernel/sync/wait_queue.h"#include "kernel/scheduler/scheduler.h"#include "arch/arch.h"#include "kernel/assert.h"#include "kernel/cpu/cpu.h"#include "kernel/signal/signal.h"Functions | |
| void | wait_queue_init (wait_queue_t *wq) |
| initialize a wait queue to empty. | |
| void | wait_queue_sleep_locked (wait_queue_t *wq, bool interruptible) |
| sleep on a queue: the common part of the block functions, for code that builds its own (the timed queues). | |
| void | wait_queue_block (wait_queue_t *wq) |
| block the current process on this queue and yield the CPU. | |
| void | wait_queue_block_interruptible (wait_queue_t *wq) |
| like wait_queue_block, but a signal for the process also wakes it. | |
| void | wait_queue_wait_word (wait_queue_t *wq, const volatile uint32_t *word, uint32_t seen) |
| sleep on a queue while a counter has the value the caller saw, until a wake or a signal. | |
| void | wait_queue_block_locked (wait_queue_t *wq, spinlock_t *lock) |
| block on this queue while holding a spinlock, releasing the lock for as long as the process sleeps and holding it again on return. | |
| void | wait_queue_block_locked_interruptible (wait_queue_t *wq, spinlock_t *lock) |
| like wait_queue_block_locked, but a signal for the process also wakes it. | |
| bool | wait_queue_interrupt (process_t *proc) |
| take a process out of the queue it sleeps on, if it sleeps interruptibly, and make it runnable (a signal arrived). | |
| void | wait_queue_wake_one (wait_queue_t *wq) |
| wake the process at the head of the queue, if any. | |
| void | wait_queue_wake_all_locked (wait_queue_t *wq) |
| wait_queue_wake_all() for a caller that holds sched_lock. | |
| void | wait_queue_wake_all (wait_queue_t *wq) |
| wake every process on the queue. | |
| void wait_queue_init | ( | wait_queue_t * | wq | ) |
initialize a wait queue to empty.
| wq | the queue to initialize. |
| void wait_queue_sleep_locked | ( | wait_queue_t * | wq, |
| bool | interruptible ) |
sleep on a queue: the common part of the block functions, for code that builds its own (the timed queues).
call it with sched_lock held and interrupts masked. an interruptible sleep with a signal pending returns at once. it returns with sched_lock held.
| wq | the queue to sleep on. |
| interruptible | true if a signal wakes the process. |
| void wait_queue_block | ( | wait_queue_t * | wq | ) |
block the current process on this queue and yield the CPU.
the process is marked BLOCKED, removed from the scheduler, and appended to the queue. returns only once another context has woken it, at which point it is runnable again.
| wq | the queue to block on. |
| void wait_queue_block_interruptible | ( | wait_queue_t * | wq | ) |
like wait_queue_block, but a signal for the process also wakes it.
the caller re-tests its condition and signal_pending() after the return.
| wq | the queue to block on. |
| void wait_queue_wait_word | ( | wait_queue_t * | wq, |
| const volatile uint32_t * | word, | ||
| uint32_t | seen ) |
sleep on a queue while a counter has the value the caller saw, until a wake or a signal.
a waker changes the counter, then wakes the queue: a change before the sleep is seen, a later one finds the process asleep. for a condition that no single lock guards (waitpid).
| wq | the queue to sleep on. |
| word | the counter. |
| seen | the value the caller read before it tested its condition. |
| void wait_queue_block_locked | ( | wait_queue_t * | wq, |
| spinlock_t * | lock ) |
block on this queue while holding a spinlock, releasing the lock for as long as the process sleeps and holding it again on return.
this is the check-then-sleep pattern: take the lock, test a condition, and if it is not met call this. the lock is held from the test until the process is on the queue, so a waker, which takes the lock to change the condition, cannot slip in between and be lost. callers re-test the condition in a loop after waking.
| wq | the queue to block on. |
| lock | a lock taken with spin_lock_irqsave() by the caller. |
| void wait_queue_block_locked_interruptible | ( | wait_queue_t * | wq, |
| spinlock_t * | lock ) |
like wait_queue_block_locked, but a signal for the process also wakes it.
the caller re-tests its condition and signal_pending() after the return.
| wq | the queue to block on. |
| lock | a lock taken with spin_lock_irqsave() by the caller. |
take a process out of the queue it sleeps on, if it sleeps interruptibly, and make it runnable (a signal arrived).
it takes sched_lock.
| proc | the process. |
| void wait_queue_wake_one | ( | wait_queue_t * | wq | ) |
wake the process at the head of the queue, if any.
the woken process is marked READY and handed back to the scheduler.
| wq | the queue to wake from. |
| void wait_queue_wake_all_locked | ( | wait_queue_t * | wq | ) |
wait_queue_wake_all() for a caller that holds sched_lock.
| wq | the queue to drain. |
| void wait_queue_wake_all | ( | wait_queue_t * | wq | ) |
wake every process on the queue.
| wq | the queue to drain. |