AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
waitq.h
Go to the documentation of this file.
1#ifndef _SYS_WAITQ_H
2#define _SYS_WAITQ_H
3
4#include <ds/list.h>
5
6struct thread;
7
8/*
9 * A wait queue holds the threads sleeping until something happens: data
10 * to read, room to write, a child to exit, a disk transfer to finish. A
11 * thread sleeps on one with waitq_sleep(); whatever it waits for wakes
12 * them all up with waitq_wakeup() when it happens, and each thread looks
13 * again. See sys/waitq.c.
14 *
15 * The threads are linked through their `run_link`, which is on the ready
16 * list instead while they can run, so going to sleep or waking up
17 * allocates nothing. `{0}` initializes a wait queue.
18 */
19struct waitq {
20 struct list threads;
21};
22
23/* Puts the current thread to sleep until woken up, or until a signal. */
24int waitq_sleep(struct waitq *waitq);
25
26/* Puts the current thread to sleep until woken up, whatever signals come. */
27void waitq_sleep_unint(struct waitq *waitq);
28
29/* Wakes up every thread on `waitq`, and every thread polling it. */
30void waitq_wakeup(struct waitq *waitq);
31
32/* Wakes up every thread on `waitq`, but not the threads polling it. */
33void waitq_wakeup_nopoll(struct waitq *waitq);
34
35/* Wakes up `thread`, if it is sleeping on a wait queue. */
36void thread_wakeup(struct thread *thread);
37
38/* Registers a wait queue that the current thread, in select() or poll(),
39 * waits for (NULL: any). */
40int poll_register(struct waitq *waitq);
41
42/* Removes the registrations of `thread`. */
43void poll_unregister(struct thread *thread);
44
45#endif /* ! _SYS_WAITQ_H */
A list: its first and last nodes, and how many there are.
Definition list.h:37
A thread.
Definition thread.h:23
Definition waitq.h:19
struct list threads
Definition waitq.h:20
void thread_wakeup(struct thread *thread)
Wakes up one thread, if it is sleeping on a wait queue.
Definition waitq.c:216
void waitq_wakeup_nopoll(struct waitq *waitq)
Wakes up every thread sleeping on a wait queue, but not the threads polling it.
Definition waitq.c:196
void waitq_wakeup(struct waitq *waitq)
Wakes up every thread sleeping on a wait queue, and every thread polling it.
Definition waitq.c:178
void poll_unregister(struct thread *thread)
Removes every registration of a thread, when it stops waiting (it was woken up, or it is going away).
Definition waitq.c:144
void waitq_sleep_unint(struct waitq *waitq)
Puts the current thread to sleep on a wait queue until it is woken up, whatever signals come meanwhil...
Definition waitq.c:67
int waitq_sleep(struct waitq *waitq)
Puts the current thread to sleep on a wait queue until it is woken up.
Definition waitq.c:50
int poll_register(struct waitq *waitq)
Registers a wait queue that the current thread, in select() or poll(), waits for: a wakeup of that qu...
Definition waitq.c:112