aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-09-20 19:14:31 -0400
committernodist <kevin.comas.git@gmail.com>2026-09-20 19:14:31 -0400
commitd93466b950ff760a1dd7fd0c2d8ae72c8f1ee0b5 (patch)
tree0bb220009fd115388b9d35f19ffcda890b0684b5
parent260e50d627aea535abcd9d9902c1b4ae56da4c54 (diff)
change thread section to process
-rw-r--r--include/kpl.h6
-rw-r--r--include/kpl/io.h4
-rw-r--r--include/kpl/process.h44
-rw-r--r--include/kpl/system.h2
-rw-r--r--include/kpl/thread.h10
-rw-r--r--include/kpl/type.h5
6 files changed, 59 insertions, 12 deletions
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 <stdint.h>
#include <stdbool.h>
#include <string.h>
+#include <pthread.h>
+#include <semaphore.h>
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;