From d93466b950ff760a1dd7fd0c2d8ae72c8f1ee0b5 Mon Sep 17 00:00:00 2001 From: nodist Date: Sun, 20 Sep 2026 19:14:31 -0400 Subject: change thread section to process --- include/kpl.h | 6 ++++-- include/kpl/io.h | 4 ++++ include/kpl/process.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/kpl/system.h | 2 ++ include/kpl/thread.h | 10 ---------- include/kpl/type.h | 5 +++++ 6 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 include/kpl/process.h delete mode 100644 include/kpl/thread.h diff --git a/include/kpl.h b/include/kpl.h index c4450ca..0e17ac6 100644 --- a/include/kpl.h +++ b/include/kpl.h @@ -5,7 +5,7 @@ #include "kpl/macro.h" #include "kpl/io.h" -#include "kpl/thread.h" +#include "kpl/process.h" typedef enum : uint32_t { KPL_CONFIG_FLAG_EVAL = 1 << 0, @@ -26,6 +26,8 @@ bool kpl_config_valid_module_exension(kpl_config *config, const char *module_nam int32_t kpl_config_parse_args(kpl_config *config, const int32_t argc, const char *argv[]); -typedef struct { +typedef struct _kpl_env { kpl_config config; + kpl_io io; + kpl_process process; } kpl_env; diff --git a/include/kpl/io.h b/include/kpl/io.h index 2b33755..9a85d1f 100644 --- a/include/kpl/io.h +++ b/include/kpl/io.h @@ -14,3 +14,7 @@ typedef enum : int32_t { typedef struct { int32_t queue_pow; } kpl_config_io; + +typedef struct { + +} kpl_io; diff --git a/include/kpl/process.h b/include/kpl/process.h new file mode 100644 index 0000000..d46fd2f --- /dev/null +++ b/include/kpl/process.h @@ -0,0 +1,44 @@ + +#pragma once + +// Kpl threads, allocators, atomic queues and garbage collection + +#include "kpl/macro.h" + +typedef struct { + int32_t 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); + +typedef struct _kpl_task { + struct _kpl_task *_Atomic next, *join; + // TODO + kpl_result result; + int32_t thread_id; + _Atomic bool join_ready; +} 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; +} kpl_thread; + +typedef struct { + _Atomic ssize_t total_priority; + kpl_thread *threads; +} kpl_process; diff --git a/include/kpl/system.h b/include/kpl/system.h index 06e8ad3..201c1b6 100644 --- a/include/kpl/system.h +++ b/include/kpl/system.h @@ -8,3 +8,5 @@ #include #include #include +#include +#include diff --git a/include/kpl/thread.h b/include/kpl/thread.h deleted file mode 100644 index 7304340..0000000 --- a/include/kpl/thread.h +++ /dev/null @@ -1,10 +0,0 @@ - -#pragma once - -// Kpl threads, allocators ad atomic queues - -#include "kpl/macro.h" - -typedef struct { - int32_t count; -} kpl_config_thread; diff --git a/include/kpl/type.h b/include/kpl/type.h index b18f6ae..b068080 100644 --- a/include/kpl/type.h +++ b/include/kpl/type.h @@ -27,3 +27,8 @@ typedef union { double f64; void *ptr; } kpl_value; + +typedef struct { + kpl_value value; + int64_t tag; +} kpl_result; -- cgit v1.2.3