diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-06-12 15:22:19 -0400 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-06-12 15:22:19 -0400 |
| commit | 89418faafd87cbbf0b36bc8bf916904a170073f6 (patch) | |
| tree | ea5b619a973ad83715de82a432565fba988a535f /docs/application/shared.md | |
| parent | 20a19f433956f063d8048f032aaf5dcce1d61e7c (diff) | |
use gnu23
Diffstat (limited to 'docs/application/shared.md')
| -rw-r--r-- | docs/application/shared.md | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/docs/application/shared.md b/docs/application/shared.md index 753bd82..cbb773e 100644 --- a/docs/application/shared.md +++ b/docs/application/shared.md @@ -6,36 +6,36 @@ ```c typedef struct _kpl_shared { - POOL_HEADER(_kpl_shared); - _Atomic bool mutating; + KPL_POOL_HEADER(_kpl_shared); + atomic_flag mutating; bool mark; kpl_class class; kpl_task *queue_head, queue_tail; - pthread_spinlock_t lock; + pthread_mutex_t queue_mutex; } kpl_shared; -static _Atomic int32_t shared_threads; +static atomic_int_fast32_t shared_threads_marked; -static pthread_mutex_t shared_head_mutex; +static kpl_shared *shared_pool_sweep, *shared_pool; -static kpl_shared *shared_head_sweep, *shared_head; +static pthread_mutex_t shared_pool_mutex; ``` ## Tracing 1. Once triggered add a init task to the async queue -2. This task moves the `shared_head` to the `shared_head_sweep` and sets the `shared_wait` to off for each thread +2. This task moves the `shared_pool` to the `shared_pool_sweep` and sets the `shared_wait` to off for each thread 3. Each thread will run down its queue queue marking found shared objects -3. Once all have run and `shared_threads == available_threads` add a mark and sweep task to the async queue +3. Once all have run and `shared_threads_marked == available_threads` add a mark and sweep task to the async queue 4. The async queue is moved to a temp queue and as each item on the tmep queue is marked it is moved back to the async queue -5. A sweep on the `shared_head_sweep` is done -6. What remains on the `shared_head_sweep` is added to `shared_head` +5. A sweep on the `shared_pool_sweep` is done +6. What remains on the `shared_pool_sweep` is added to `shared_pool` ## Mutating 1. Check if state of `mutating` - 1. If false, set to true and add the task to the `async_queue_head` - 2. Once complete lock `lock` and check the `queue_head` + 1. If false, set to true and add the task to the `async_queue_pool` + 2. Once complete lock `queue_mutex` and check the `queue_pool` 3. If empty set the state of `mutating` to false 4. Else queue the next task -2. If the state of `mutating` is true add the task to `queue_tail` +2. If the state of `mutating` is true add, lock `queue_mutex` the task to `queue_tail` |
