blob: f597d8db8b6551720917547b9c81ccb6e9d05ef7 (
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
29
30
31
32
33
34
35
36
37
38
|
# Shared
---
## Object Definitions
```c
typedef struct _kpl_shared {
KPL_SLAB_HEADER(struct _kpl_shared);
kpl_class data;
kpl_mutex mutex;
bool mark;
} kpl_shared;
_Atomic uint32_t shared_threads_makred;
static kpl_shared *shared_mark_head, *shared_head;
static kpl_mutex shared_head_mutex;
```
# Garbage Collection
## Initiation Task
1. Move `shared_head` to `shared_mark_head`
2. Add a mark task to each of the threads
## Mark Task(s)
1. Run gc interface on each task in the queue
2. Increase `shared_threads_makred`
3. If `shared_threads_makred` is equal to `avaiable_threads` schedule sweep task
## Sweep Task
1. Go through `shared_mark_head` freeing anything that is not marked
2. Add anything left on `shared_mark_head` to `shared_head`
|