ReactOS 0.4.17-dev-1190-g4c812f4
mutex.h
Go to the documentation of this file.
1#pragma once
2
4#include <uacpi/kernel_api.h>
5
6#ifndef UACPI_BAREBONES_MODE
7
9
12
13/*
14 * A native mutex is a semaphore that has exactly one unit: whoever takes it
15 * holds the mutex until they give it back.
16 *
17 * Note that there's no such thing as an owner as far as the kernel is
18 * concerned. Whenever we need one we keep track of it ourselves, and some of
19 * our locks rely on being released by a thread other than the one that has
20 * acquired them, see uacpi_rw_lock.
21 */
23{
25}
26
28{
30}
31
33{
34 if (uacpi_unlikely(mtx == UACPI_NULL))
36
37 return uacpi_kernel_wait_for_semaphore(mtx, 0xFFFF);
38}
39
42);
43
45{
46 if (uacpi_unlikely(mtx == UACPI_NULL))
48
50 return UACPI_STATUS_OK;
51}
52
54 uacpi_handle mtx
55)
56{
57 if (mtx == UACPI_NULL)
58 return UACPI_STATUS_OK;
59
60 return uacpi_kernel_wait_for_semaphore(mtx, 0xFFFF);
61}
62
64 uacpi_handle mtx
65)
66{
67 if (mtx == UACPI_NULL)
68 return UACPI_STATUS_OK;
69
71 return UACPI_STATUS_OK;
72}
73
74/*
75 * A native event is a semaphore that starts out with no units, and is given
76 * one every time that it's signaled.
77 */
79{
81}
82
84{
86}
87
90)
91{
93}
94
96{
98}
99
100/*
101 * There's no such thing as resetting a semaphore, so take every unit that the
102 * event has instead. Nothing is able to signal it in the meantime: the only
103 * events that are ever reset are the AML ones, which are only signaled by AML,
104 * and that can't be executed while the caller is holding the namespace lock.
105 */
107{
109}
110
115};
116
119
122
127};
128
131
134
137
138#endif // !UACPI_BAREBONES_MODE
uacpi_status uacpi_rw_lock_deinit(struct uacpi_rw_lock *lock)
Definition: mutex.c:331
uacpi_status uacpi_acquire_native_mutex_with_timeout(uacpi_handle mtx, uacpi_u16 timeout)
static uacpi_status uacpi_release_native_mutex(uacpi_handle mtx)
Definition: mutex.h:44
uacpi_status uacpi_recursive_lock_deinit(struct uacpi_recursive_lock *lock)
Definition: mutex.c:265
uacpi_status uacpi_acquire_aml_mutex(uacpi_mutex *, uacpi_u16 timeout)
Definition: mutex.c:199
static uacpi_status uacpi_acquire_native_mutex_may_be_null(uacpi_handle mtx)
Definition: mutex.h:53
static void uacpi_free_native_mutex(uacpi_handle mtx)
Definition: mutex.h:27
static uacpi_status uacpi_acquire_native_mutex(uacpi_handle mtx)
Definition: mutex.h:32
uacpi_status uacpi_rw_lock_init(struct uacpi_rw_lock *lock)
Definition: mutex.c:314
static void uacpi_signal_native_event(uacpi_handle evt)
Definition: mutex.h:95
uacpi_status uacpi_recursive_lock_init(struct uacpi_recursive_lock *lock)
Definition: mutex.c:253
uacpi_status uacpi_rw_unlock_read(struct uacpi_rw_lock *lock)
Definition: mutex.c:369
uacpi_status uacpi_rw_unlock_write(struct uacpi_rw_lock *lock)
Definition: mutex.c:389
static void uacpi_reset_native_event(uacpi_handle evt)
Definition: mutex.h:106
static uacpi_handle uacpi_create_native_mutex(void)
Definition: mutex.h:22
static uacpi_handle uacpi_create_native_event(void)
Definition: mutex.h:78
uacpi_status uacpi_release_aml_mutex(uacpi_mutex *)
Definition: mutex.c:239
uacpi_bool uacpi_this_thread_owns_aml_mutex(uacpi_mutex *)
Definition: mutex.c:191
uacpi_status uacpi_rw_lock_read(struct uacpi_rw_lock *lock)
Definition: mutex.c:351
static void uacpi_free_native_event(uacpi_handle evt)
Definition: mutex.h:83
uacpi_status uacpi_recursive_lock_acquire(struct uacpi_recursive_lock *lock)
Definition: mutex.c:285
uacpi_status uacpi_rw_lock_write(struct uacpi_rw_lock *lock)
Definition: mutex.c:384
static uacpi_status uacpi_release_native_mutex_may_be_null(uacpi_handle mtx)
Definition: mutex.h:63
uacpi_status uacpi_recursive_lock_release(struct uacpi_recursive_lock *lock)
Definition: mutex.c:305
static uacpi_bool uacpi_wait_for_native_event(uacpi_handle evt, uacpi_u16 timeout)
Definition: mutex.h:88
#define uacpi_unlikely(expr)
Definition: compiler.h:88
size_t uacpi_size
Definition: types.h:37
bool uacpi_bool
Definition: types.h:31
uint16_t uacpi_u16
Definition: types.h:20
#define UACPI_NULL
Definition: types.h:33
uacpi_status
Definition: status.h:10
@ UACPI_STATUS_INVALID_ARGUMENT
Definition: status.h:18
@ UACPI_STATUS_OK
Definition: status.h:11
uacpi_status uacpi_kernel_wait_for_semaphore(uacpi_handle, uacpi_u16)
uacpi_handle uacpi_kernel_create_semaphore(uacpi_u32 initial_units)
void uacpi_kernel_free_semaphore(uacpi_handle)
void uacpi_kernel_signal_semaphore(uacpi_handle)
Definition: dhcpd.h:248
uacpi_thread_id owner
Definition: mutex.h:114
uacpi_handle mutex
Definition: mutex.h:112
uacpi_size depth
Definition: mutex.h:113
uacpi_size num_readers
Definition: mutex.h:126
uacpi_handle read_mutex
Definition: mutex.h:124
uacpi_handle write_mutex
Definition: mutex.h:125
rwlock_t lock
Definition: tcpcore.h:0