AquilaOS documentation
How it works, and its code
Toggle main menu visibility
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
6
struct
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
*/
19
struct
waitq
{
20
struct
list
threads
;
21
};
22
23
/* Puts the current thread to sleep until woken up, or until a signal. */
24
int
waitq_sleep
(
struct
waitq
*
waitq
);
25
26
/* Puts the current thread to sleep until woken up, whatever signals come. */
27
void
waitq_sleep_unint
(
struct
waitq
*
waitq
);
28
29
/* Wakes up every thread on `waitq`, and every thread polling it. */
30
void
waitq_wakeup
(
struct
waitq
*
waitq
);
31
32
/* Wakes up every thread on `waitq`, but not the threads polling it. */
33
void
waitq_wakeup_nopoll
(
struct
waitq
*
waitq
);
34
35
/* Wakes up `thread`, if it is sleeping on a wait queue. */
36
void
thread_wakeup
(
struct
thread
*
thread
);
37
38
/* Registers a wait queue that the current thread, in select() or poll(),
39
* waits for (NULL: any). */
40
int
poll_register
(
struct
waitq
*
waitq
);
41
42
/* Removes the registrations of `thread`. */
43
void
poll_unregister
(
struct
thread
*
thread
);
44
45
#endif
/* ! _SYS_WAITQ_H */
list.h
list
A list: its first and last nodes, and how many there are.
Definition
list.h:37
thread
A thread.
Definition
thread.h:23
waitq
Definition
waitq.h:19
waitq::threads
struct list threads
Definition
waitq.h:20
thread_wakeup
void thread_wakeup(struct thread *thread)
Wakes up one thread, if it is sleeping on a wait queue.
Definition
waitq.c:216
waitq_wakeup_nopoll
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
waitq_wakeup
void waitq_wakeup(struct waitq *waitq)
Wakes up every thread sleeping on a wait queue, and every thread polling it.
Definition
waitq.c:178
poll_unregister
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
waitq_sleep_unint
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
waitq_sleep
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
poll_register
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
kernel
include
sys
waitq.h
Generated by
1.18.0