summaryrefslogtreecommitdiff
path: root/docs/application
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-06-28 13:41:22 -0400
committernodist <kevin.comas.git@gmail.com>2026-06-28 13:41:22 -0400
commitcf9285b1dbdf687630076149413f16e5d4af82e8 (patch)
tree7c10f7587cab9cd40c0d1b9e019cd4a2135e7193 /docs/application
parent254059e2ea2df0cd63cf75d836ac9ebe00a28302 (diff)
type body object definitions and garbage collection algoHEADmain
Diffstat (limited to 'docs/application')
-rw-r--r--docs/application/identifier.md4
-rw-r--r--docs/application/index.md13
-rw-r--r--docs/application/interface.md2
-rw-r--r--docs/application/memory.md13
-rw-r--r--docs/application/namespace.md2
-rw-r--r--docs/application/queue.md2
-rw-r--r--docs/application/shared.md24
-rw-r--r--docs/application/thread.md4
-rw-r--r--docs/application/type.md6
9 files changed, 54 insertions, 16 deletions
diff --git a/docs/application/identifier.md b/docs/application/identifier.md
index 8f85b15..47dcd79 100644
--- a/docs/application/identifier.md
+++ b/docs/application/identifier.md
@@ -7,9 +7,9 @@ Store vars, types and symbols as compressed strings
## Object Definitions
```c
-#define KPL_IDENTIFIER_PARTS 9
+#define KPL_IDENTIFIER_PARTS 6
-// TODO 90 charaters of [A-Za-z0-9_] in 72 bytes
+// TODO 60 charaters of [A-Za-z0-9_] in 48 bytes
typedef struct {
uint64_t parts[KPL_IDENTIFIER_PARTS];
diff --git a/docs/application/index.md b/docs/application/index.md
index 279ff6c..d99b941 100644
--- a/docs/application/index.md
+++ b/docs/application/index.md
@@ -32,6 +32,12 @@
## Startup
+1. Configuration
+2. Initialize tasks
+3. Initialize types
+4. Initialize allocators
+5. Initialize IO
+
## Main
### Module
@@ -42,7 +48,7 @@
1. ##### [Register](../lifecycle/register.md)
2. ##### [Parse](../lifecycle/parse.md)
-3. ##### Scan
+3. ##### Scope
4. ##### Import
5. ##### Check
6. ##### Eval
@@ -52,3 +58,8 @@
10. ##### Notify
## Shutdown
+
+1. Clean up IO
+2. Clean up allocators
+3. Clean up types
+4. Clean up tasks
diff --git a/docs/application/interface.md b/docs/application/interface.md
index 6f33f61..5acfba7 100644
--- a/docs/application/interface.md
+++ b/docs/application/interface.md
@@ -28,6 +28,8 @@ typedef ssize_t kpl_any_cmp_fn(const kpl_any a, const kpl_any b);
typedef int32_t kpl_write(const kpl_ant a, FILE *file, int32_t idnt, uint32_t opts);
+// TODO GC FUNCTION
+
typedef void kpl_any_free_fn(kpl_any a);
typedef struct {
diff --git a/docs/application/memory.md b/docs/application/memory.md
index f5f457c..a8e75b8 100644
--- a/docs/application/memory.md
+++ b/docs/application/memory.md
@@ -45,12 +45,17 @@ typdef strcut _kpl_slab_tree_obj {
KPL_SLAB_TREE_HEADER(struct _kpl_slab_tree_obj);
} kpl_slab_tree_obj;
+typdef struct _kpl_slab_bucket {
+ struct _kpl_slab_bucket *next;
+ uint8_t byte_obj_array[];
+} kpl_slab_bucket;
+
typedef struct _kpl_slab {
- KPL_ALLOC_HEADER(struct _kpl_slab);
- uint32_t obj_size, byte_index;
+ uint16_t obj_count, obj_index;
+ uint32_t obj_size;
kpl_slab_obj *pool;
+ kpl_slab_bucket *bucket;
kpl_mutex mutex;
- uint8_t byte_array[];
} kpl_slab;
```
@@ -64,8 +69,6 @@ Each bucket in the `kpl_alloc.pool` represents two to the power of the bucket in
# Slab
-Allocated by `kpl_alloc`
-
## Pooling
Objects for reuse are stored as a list by the `kpl_slab_obj.prev` on `kpl_slab.pool`
diff --git a/docs/application/namespace.md b/docs/application/namespace.md
index 3f34f61..38752ce 100644
--- a/docs/application/namespace.md
+++ b/docs/application/namespace.md
@@ -6,7 +6,7 @@
```c
typedef struct _kpl_export {
- KPL_ALLOC_TREE_HEADER(struct _kpl_export);
+ KPL_SLAB_TREE_HEADER(struct _kpl_export);
kpl_type_ptr type;
} kpl_export;
diff --git a/docs/application/queue.md b/docs/application/queue.md
index 2807ce9..cd9f363 100644
--- a/docs/application/queue.md
+++ b/docs/application/queue.md
@@ -11,7 +11,7 @@ typedef struct _kpl_queue_item {
} kpl_queue_item;
typedef struct _kpl_queue {
- KPL_ALLOC_HEADER(struct _kpl_queue);
+ KPL_SLAB_HEADER(struct _kpl_queue);
size_t item_length;
kpl_interface *interface;
kpl_pool_any *head, *tail;
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`
diff --git a/docs/application/thread.md b/docs/application/thread.md
index ff03183..d564d20 100644
--- a/docs/application/thread.md
+++ b/docs/application/thread.md
@@ -14,7 +14,7 @@ typedef void kpl_task_fn(kpl_task *t);
typedef struct _task {
task *_Atomic next, *join;
kpl_class state[KPL_TASK_STATE_SIZE];
- kpl_result return_value;
+ kpl_result result;
task_fn *fn;
int32_t thread_id;
int16_t state_length;
@@ -24,7 +24,6 @@ typedef struct _task {
#define KPL_TASK_SLAB_SIZE 50
typedef struct _kpl_task_slab {
- size_t array_index;
struct _kpl_task_slab *next;
kpl_task array[KPL_TASK_SLAB_SIZE];
} kpl_task_slab;
@@ -43,6 +42,7 @@ typedef struct {
typedef struct {
kpl_task_queue queue;
_Atomic ssize_t priority;
+ size_t slab_array_index;
kpl_task_slab *slab;
kpl_task *pool;
sem_t counter;
diff --git a/docs/application/type.md b/docs/application/type.md
index 43a8f2c..40546c1 100644
--- a/docs/application/type.md
+++ b/docs/application/type.md
@@ -17,17 +17,17 @@ typedef enum {
} kpl_type_qualifiers;
typedef union {
- // 96 Bytes Max
+ // 64 Bytes Max
} kpl_type_body;
typedef struct {
kpl_type_template template;
uint8_t qualifiers;
uint16_t modifiers;
- kpl_ptr self, prev, next;
- uint32_t token_position,
uint16_t token_length, token_line;
+ uint32_t token_position;
_Atomic int32_t ref_count;
+ kpl_ptr self, prev, next;
kpl_namespace_module *module;
kpl_type_body body;
} kpl_type;