PatchworkOS  c9fea19
A non-POSIX operating system.
Loading...
Searching...
No Matches
futex.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/sched/wait.h>
4#include <kernel/utils/map.h>
5
6#include <sys/proc.h>
7
8/**
9 * @brief Fast User-space Mutex.
10 * @defgroup kernel_sync_futex Fast User-space Mutex
11 * @ingroup kernel_sync
12 *
13 * Patchwork uses a Futex (Fast User-space Mutex) implementation to let user space implement synchronization primitives
14 * like mutexes and conditional variables efficiently.
15 *
16 * @{
17 */
18
19/**
20 * @brief Futex structure.
21 * @struct futex_t
22 */
28
29/**
30 * @brief Per-process futex context.
31 * @struct futex_ctx_t
32 */
33typedef struct
34{
38
39/**
40 * @brief Initialize a per-process futex context.
41 *
42 * @param ctx Pointer to the futex context to initialize.
43 */
45
46/**
47 * @brief Deinitialize a per-process futex context.
48 * *
49 * @param ctx Pointer to the futex context to deinitialize.
50 */
52
53/** @} */
void futex_ctx_deinit(futex_ctx_t *ctx)
Deinitialize a per-process futex context. *.
Definition futex.c:22
void futex_ctx_init(futex_ctx_t *ctx)
Initialize a per-process futex context.
Definition futex.c:16
Per-process futex context.
Definition futex.h:34
lock_t lock
Definition futex.h:36
map_t futexes
Definition futex.h:35
Futex structure.
Definition futex.h:24
map_entry_t entry
Definition futex.h:25
wait_queue_t queue
Definition futex.h:26
A simple ticket lock implementation.
Definition lock.h:43
Map entry structure.
Definition map.h:68
Hash map structure.
Definition map.h:89
The primitive that threads block on.
Definition wait.h:182