blob: b2760c58937cb04ca0d974f6c675f5e9eacdc6d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# Shared
---
## Object Definition
```c
typedef struct _kpl_shared {
KPL_SLAB_HEADER(_kpl_shared);
void *data;
kpl_atomic_queue queue;
_Atomic uint32_t lock;
bool mark;
} kpl_shared;
```
## Mutating
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 mutator task, otherwise the thread moves on
### Mutator Task
1. Get task from `queue` and run task
2. After task completion, do `value = --lock`, stop if `value` is `0`, otherwise repeat
## Garbage Collection
|