diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/application/gc.md | 32 | ||||
| -rw-r--r-- | docs/application/io.md | 2 | ||||
| -rw-r--r-- | docs/application/thread.md | 3 |
3 files changed, 32 insertions, 5 deletions
diff --git a/docs/application/gc.md b/docs/application/gc.md index 7353db9..9364e12 100644 --- a/docs/application/gc.md +++ b/docs/application/gc.md @@ -5,8 +5,34 @@ ## Object Definition ```c -typedef struct _kpl_gc_count { - _Atomic size_t ref_count; +typedef struct _kpl_gc { + POOL_HEADER(_kpl_gc); + union { + _Atomic int32_t ref_count; + _Atomic bool mark; + } method; kpl_any any; -} kpl_gc_count; + pthread_mutex_t mutex; +} kpl_gc; + +static _Atomic size_t marked_threads; + +static kpl_gc *old_gc_head, *gc_head, *gc_tail; ``` + +## Counting + +`ref_count` starts at 1 + +Each assign increments the reference count, each time it goes out of scope the reference count is decreased + +When `ref_count` hits 0, data is freed + +## Tracing + +1. Once triggered add a init task to the async queue +2. This task moves the `gc_head` to the `old_gc_head` and sets the `gc_wait` to off for each thread +3. Each thread will run down its queue queue marking found gc objects +3. Once all have run and `marked_threads == available_threads` add a mark and sweep task to the async queue +4. Async task goes down async queue and does final mark, then a sweep on the `old_gc_head` is done +5. What remains on the `old_gc_head` is added to the gc tail diff --git a/docs/application/io.md b/docs/application/io.md index 50e21ff..7ac8dd8 100644 --- a/docs/application/io.md +++ b/docs/application/io.md @@ -2,4 +2,4 @@ --- -All IO is done through lib_uring +All IO is done through linux io_uring diff --git a/docs/application/thread.md b/docs/application/thread.md index 3dc0b2f..ba67a7e 100644 --- a/docs/application/thread.md +++ b/docs/application/thread.md @@ -10,7 +10,7 @@ typedef struct _kpl_task kpl_task; typedef void kpl_task_fn(kpl_task *t); typedef struct _kpl_task { - POOL_HEADER(kpl_task); + POOL_HEADER(_kpl_task); _Atomic bool join_ready; uint16_t worker_id; kpl_task_fn *fn; @@ -20,6 +20,7 @@ typedef struct _kpl_task { } kpl_task; typedef struct { + _Atomic bool gc_wait; kpl_task *queue_head, *queue_tail; pthread_t thread; } kpl_thread; |
