PatchworkOS
c9fea19
A non-POSIX operating system.
Theme:
Default
Round
Robot
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
*/
23
typedef
struct
24
{
25
map_entry_t
entry
;
26
wait_queue_t
queue
;
27
}
futex_t
;
28
29
/**
30
* @brief Per-process futex context.
31
* @struct futex_ctx_t
32
*/
33
typedef
struct
34
{
35
map_t
futexes
;
36
lock_t
lock
;
37
}
futex_ctx_t
;
38
39
/**
40
* @brief Initialize a per-process futex context.
41
*
42
* @param ctx Pointer to the futex context to initialize.
43
*/
44
void
futex_ctx_init
(
futex_ctx_t
* ctx);
45
46
/**
47
* @brief Deinitialize a per-process futex context.
48
* *
49
* @param ctx Pointer to the futex context to deinitialize.
50
*/
51
void
futex_ctx_deinit
(
futex_ctx_t
* ctx);
52
53
/** @} */
futex_ctx_deinit
void futex_ctx_deinit(futex_ctx_t *ctx)
Deinitialize a per-process futex context. *.
Definition
futex.c:22
futex_ctx_init
void futex_ctx_init(futex_ctx_t *ctx)
Initialize a per-process futex context.
Definition
futex.c:16
map.h
proc.h
futex_ctx_t
Per-process futex context.
Definition
futex.h:34
futex_ctx_t::lock
lock_t lock
Definition
futex.h:36
futex_ctx_t::futexes
map_t futexes
Definition
futex.h:35
futex_t
Futex structure.
Definition
futex.h:24
futex_t::entry
map_entry_t entry
Definition
futex.h:25
futex_t::queue
wait_queue_t queue
Definition
futex.h:26
lock_t
A simple ticket lock implementation.
Definition
lock.h:43
map_entry_t
Map entry structure.
Definition
map.h:68
map_t
Hash map structure.
Definition
map.h:89
wait_queue_t
The primitive that threads block on.
Definition
wait.h:182
wait.h
include
kernel
sync
futex.h
Generated on Mon Dec 15 2025 05:10:34 for PatchworkOS by
1.9.8