summaryrefslogtreecommitdiff
path: root/kernel/kmalloc.c
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-07 03:01:28 +0200
committerMiguel <m.i@gmx.at>2018-09-07 03:01:28 +0200
commitaa4b4c6c1918a51318709761873d1c5e248a831d (patch)
treebdcfe7be159cc778d113538722e119a665a47738 /kernel/kmalloc.c
parentef4943053475cd8bf341c42dd0b538bc630b92a3 (diff)
apic timer smp
Diffstat (limited to 'kernel/kmalloc.c')
-rw-r--r--kernel/kmalloc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/kernel/kmalloc.c b/kernel/kmalloc.c
index ec714c4..6a5812a 100644
--- a/kernel/kmalloc.c
+++ b/kernel/kmalloc.c
@@ -1,7 +1,7 @@
-
#include "kmalloc.h"
#include "kernel.h"
+#include "spinlock.h"
static uint8_t data[KMALLOC_MEM_SIZE]; // bytes
@@ -32,11 +32,15 @@ static void kmallocinit()
uint32_t kballoc(uint32_t size)
{
size*=4096;
+
+ spinlock_spin(SPINLOCK_ALLOC);
+
+ if(!init)kmallocinit();
- if(!init)kmallocinit();
+ uint32_t old=next;
+ next+=size;
- uint32_t old=next;
- next+=size;
+ spinlock_release(SPINLOCK_ALLOC);
if(next>=first+KMALLOC_MEM_SIZE)
{