|
My Kernel v0.1.0
|
Waiting queue. More...

Data Structures | |
| struct | waitqueue |
| Waiting Queue. More... | |
Macros | |
| #define | __WAITQUEUE_INIT(_queue) |
| Default init value. | |
| #define | __INIT_WAITQUEUE(_queue) _queue = __WAITQUEUE_INIT(_queue) |
| Initialize a waitqueue. | |
| #define | DECLARE_WAITQUEUE(_queue) struct waitqueue INIT_WAITQUEUE(_queue) |
| Declare and initialize a waitqueue. | |
| #define | waitqueue_enqueue(waitqueue, thread) |
| Mark a thread as waiting for the event to finish. | |
Functions | |
| bool | waitqueue_is_empty (struct waitqueue *) |
| Check whether anyone is waiting for this event to finish. | |
| void | waitqueue_enqueue_locked (struct waitqueue *, struct thread *) |
| Mark a thread as waiting for the event to finish. More... | |
| const struct thread * | waitqueue_peek (struct waitqueue *) |
| struct thread * | waitqueue_dequeue (struct waitqueue *) |
| Wakeup the first thread inside the queue. More... | |
| size_t | waitqueue_dequeue_all (struct waitqueue *) |
| Wakeup all the threads inside the queue. More... | |
A waitqueue is used to list threads that are waiting for a ressource before being rescheduled.
Some examples are:
All accesses to a waitqueue are placed behind a lock to make this API thread safe.
A waitqueue is used exactly as you would a regular queue. The only difference is that when a thread is queued it is automatically marked as waiting, and resumes running once dequeued.
| size_t waitqueue_dequeue_all | ( | struct waitqueue * | queue | ) |
This function is equivalent to waitqueue_enqueue. It should be called when holding the queue's lock.
NOTE: This function releases the lock held by the caller