summaryrefslogtreecommitdiff
path: root/docs/application/memory.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/application/memory.md')
-rw-r--r--docs/application/memory.md56
1 files changed, 48 insertions, 8 deletions
diff --git a/docs/application/memory.md b/docs/application/memory.md
index fbc6b67..61a59f9 100644
--- a/docs/application/memory.md
+++ b/docs/application/memory.md
@@ -5,10 +5,30 @@
## Object Definitions
```c
-#define KPL_SLAB_HEADER(STRUCT) STRCUT *next
+#define KPL_ALLOC_HEADER(STRCUT) size_t obj_size : 56; int8_t tree_weight; STRCUT *prev
+
+typedef struct _kpl_alloc_obj {
+ KPL_ALLOC_HEADER(_kpl_alloc_obj);
+} kpl_alloc_obj;
+
+#define KPL_ALLOC_TREE_HEADER(STRCUT) KPL_ALLOC_TREE_HEADER(STRUCT); STRUCT *next, *parent
+
+typdef struct _kpl_alloc_tree_obj {
+ KPL_ALLOC_TREE_HEADER(struct _kpl_alloc_tree_obj);
+} kpl_alloc_tree_obj;
+
+#define KPL_ALLOC_POOL_SIZE 56
+
+typedef struct kpl_alloc {
+ _Atomic size_t bytes_allocated;
+ kpl_mutex mutex;
+ kpl_alloc_obj *pool[KPL_ALLOC_POOL_SIZE]
+} kpl_alloc;
+
+#define KPL_SLAB_HEADER(STRUCT) STRCUT *prev
typdef strcut _kpl_slab_obj {
- KPL_SLAB_LIST_HEADER(strcut _kpl_slab_obj);
+ KPL_SLAB_HEADER(strcut _kpl_slab_obj);
} kpl_slab_obj;
#define KPL_SLAB_LIST_HEADER(STRCUT) STRCUT *prev, *next
@@ -17,15 +37,35 @@ typdef strcut _kpl_slab_list_obj {
KPL_SLAB_LIST_HEADER(strcut _kpl_slab_list_obj);
} kpl_slab_list_obj;
-#define KPL_SLAB_TREE_HEADER(STRUCT) STRUCT *parent, *left, *right, uint8_t tree_weight
+#define KPL_SLAB_TREE_HEADER(STRUCT) STRUCT *prev, *next, *parent; int8_t tree_weight
typdef strcut _kpl_slab_tree_obj {
KPL_SLAB_TREE_HEADER(struct _kpl_slab_tree_obj);
} kpl_slab_tree_obj;
-#define KPL_POOL_HEADER(STRCUT) STRCUT *parent, *left, *right, uint8_t tree_weight, uint64_t obj_size : 56
-
-typdef struct _kpl_pool_obj {
- KPL_POOL_HEADER(struct _kpl_pool_obj);
-} kpl_pool_obj;
+typedef struct _kpl_slab {
+ KPL_ALLOC_HEADER(struct _kpl_slab);
+ uint32_t obj_size, byte_index;
+ kpl_slab_obj *pool;
+ kpl_mutex mutex;
+ uint8_t byte_array[MAX_SIZE];
+} kpl_slab;
```
+
+# Alloc
+
+All allocated objects size must be aligned to the power of two
+
+## Pooling
+
+Each bucket in the `kpl_alloc.pool` represents two to the power of the bucket index
+
+# AVL Tree For Slab And Alloc
+
+# Slab
+
+Allocated by `kpl_alloc`
+
+## Pooling
+
+Objects for reuse are stored as a list by the `kpl_slab_obj.prev` on `kpl_slab.pool`