From cf9285b1dbdf687630076149413f16e5d4af82e8 Mon Sep 17 00:00:00 2001 From: nodist Date: Sun, 28 Jun 2026 13:41:22 -0400 Subject: type body object definitions and garbage collection algo --- docs/application/shared.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'docs/application/shared.md') diff --git a/docs/application/shared.md b/docs/application/shared.md index 0990ae6..f597d8d 100644 --- a/docs/application/shared.md +++ b/docs/application/shared.md @@ -11,6 +11,28 @@ typedef struct _kpl_shared { 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 +# 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` -- cgit v1.2.3