diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-09-23 12:32:31 -0400 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-09-23 12:32:31 -0400 |
| commit | 07af98f3a5a54a8736109ed031d3177508943299 (patch) | |
| tree | 032427fabed19c59349c51ce842517e6895a33b8 /include/kpl/process.h | |
| parent | d93466b950ff760a1dd7fd0c2d8ae72c8f1ee0b5 (diff) | |
add task queues
Diffstat (limited to 'include/kpl/process.h')
| -rw-r--r-- | include/kpl/process.h | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/include/kpl/process.h b/include/kpl/process.h index d46fd2f..b47e122 100644 --- a/include/kpl/process.h +++ b/include/kpl/process.h @@ -3,14 +3,25 @@ // Kpl threads, allocators, atomic queues and garbage collection -#include "kpl/macro.h" +#include "kpl/queue.h" + +typedef enum : int8_t { + KPL_CONFIG_THREAD_COUNT_AFFINITY = -1, + KPL_CONFIG_THREAD_COUNT_MAX = 127 +} kpl_config_thread_count; + +typedef enum : uint8_t { + KPL_CONFIG_THREAD_RING_POOL_COUNT = 28, + KPL_CONFIG_THREAD_RING_POOL_MIN_OBJECT_SIZE_POW2 = 5, + KPL_CONFIG_THREAD_RING_POOL_MAX_OBJECT_SIZE_POW2 = 27, + KPL_CONFIG_THREAD_RING_POOL_MIN_RING_SIZE_POW2 = 6, + KPL_CONFIG_THREAD_RING_POOL_MAX_RING_SIZE_POW2 = 20 +} kpl_config_thread_ring_pool; typedef struct { - int32_t count; + int8_t count, ring_pool_entries_pow2[KPL_CONFIG_THREAD_RING_POOL_COUNT]; } kpl_config_thread; -typedef struct _kpl_task kpl_task; - typedef struct _kpl_env kpl_env; typedef void kpl_task_fn(kpl_task *task, kpl_env *env); @@ -24,21 +35,16 @@ typedef struct _kpl_task { } kpl_task; typedef struct { - kpl_task *_Atomic head, *_Atomic tail; - struct { - kpl_task *_Atomic next; - } dummy; -} kpl_task_queue; - -typedef struct { kpl_task_queue task_queue; _Atomic ssize_t priority; // TODO - sem_t spin_counter; - pthread_t thread; + sem_t sem; + pthread_t pthread; } kpl_thread; typedef struct { + kpl_config_thread *config_thread; _Atomic ssize_t total_priority; kpl_thread *threads; + kpl_ring_queue memory_pool[KPL_CONFIG_THREAD_RING_POOL_COUNT]; } kpl_process; |
