summaryrefslogtreecommitdiff
path: root/docs/application/mutex.md
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-06-16 12:42:41 -0400
committernodist <kevin.comas.git@gmail.com>2026-06-16 12:42:41 -0400
commit7964cf08ac807ac9e7b6d579a25321a23adc9139 (patch)
tree807799f7c4dea85fca31e3532b0e06f71f0f32ea /docs/application/mutex.md
parente99f60fe8cdef48aad9aa6a1b360b600443ac659 (diff)
new layout by dependecy graph
Diffstat (limited to 'docs/application/mutex.md')
-rw-r--r--docs/application/mutex.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/application/mutex.md b/docs/application/mutex.md
new file mode 100644
index 0000000..999f5dc
--- /dev/null
+++ b/docs/application/mutex.md
@@ -0,0 +1,23 @@
+# Mutex
+
+---
+
+## Object Definitions
+
+```c
+typedef struct {
+ kpl_atomic_queue queue;
+ _Atomic int32_t lock;
+} kpl_mutex;
+```
+
+## Usage
+
+1. Before adding to the `queue` do `value = lock++`
+2. Add to the queue
+3. If `value` is `0` the thread does an async schedule of the mutex task, otherwise the thread moves on
+
+### Mutex Task
+
+1. Get task from `queue` and run task
+2. After task completion, do `value = --lock`, stop if `value` is `0`, otherwise repeat