diff options
author | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-01 17:42:36 +0200 |
---|---|---|
committer | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-01 17:42:36 +0200 |
commit | e9683297bf480f9590b0e5796f4520fb430e2e03 (patch) | |
tree | 93ef75cd154edf4c342d0a22cd56eb3670feb2b5 /src/kernel/mem | |
parent | e8cf65c07d78e3cfbac953b1b97c51998a5900df (diff) | |
download | TCE-e9683297bf480f9590b0e5796f4520fb430e2e03.tar.gz TCE-e9683297bf480f9590b0e5796f4520fb430e2e03.zip |
Now using Doug Lea's malloc for userland too. And improved stability.
Diffstat (limited to 'src/kernel/mem')
-rw-r--r-- | src/kernel/mem/_dlmalloc.c | 8 | ||||
-rw-r--r-- | src/kernel/mem/_dlmalloc.h | 5 | ||||
-rw-r--r-- | src/kernel/mem/gdt.c | 2 | ||||
-rw-r--r-- | src/kernel/mem/mem.h | 1 | ||||
-rw-r--r-- | src/kernel/mem/paging.c | 5 |
5 files changed, 17 insertions, 4 deletions
diff --git a/src/kernel/mem/_dlmalloc.c b/src/kernel/mem/_dlmalloc.c index 18dabab..30c6622 100644 --- a/src/kernel/mem/_dlmalloc.c +++ b/src/kernel/mem/_dlmalloc.c @@ -912,6 +912,14 @@ static FORCEINLINE int win32munmap(void* ptr, size_t size) { /* #define TRY_LOCK(lk) ... */ /* static MLOCK_T malloc_global_mutex = ... */ +#define MLOCK_T uint32_t +#define INITIAL_LOCK(l) (*l = MUTEX_UNLOCKED) +#define DESTROY_LOCK(l) (0) +#define ACQUIRE_LOCK(l) (mutex_lock (l)) +#define RELEASE_LOCK(l) (mutex_unlock (l)) +#define TRY_LOCK(l) (mutex_lockE(l)) +static MLOCK_T malloc_global_mutex = MUTEX_UNLOCKED; + #elif USE_SPIN_LOCKS /* First, define CAS_LOCK and CLEAR_LOCK on ints */ diff --git a/src/kernel/mem/_dlmalloc.h b/src/kernel/mem/_dlmalloc.h index a030da2..7b2e2cc 100644 --- a/src/kernel/mem/_dlmalloc.h +++ b/src/kernel/mem/_dlmalloc.h @@ -2,14 +2,19 @@ #define DEF_DLMALLOC_H #include "lib/std.h" +#include <stdlib_common.h> +#include <string.h> #define NO_MALLOC_STATS 1 #define LACKS_TIME_H #define LACKS_UNISTD_H #define LACKS_SYS_PARAM_H +#define LACKS_STDLIB_H #define USE_DL_PREFIX +#define USE_LOCKS 2 + /* Version identifier to allow people to support multiple versions */ #ifndef DLMALLOC_VERSION diff --git a/src/kernel/mem/gdt.c b/src/kernel/mem/gdt.c index 8ee403a..494aaf2 100644 --- a/src/kernel/mem/gdt.c +++ b/src/kernel/mem/gdt.c @@ -1,5 +1,5 @@ #include "gdt.h" -#include <stdlib.h> +#include <stdlib_common.h> #include <core/monitor.h> extern void gdt_flush(uint32_t); //ASM (imported from idt_.asm) diff --git a/src/kernel/mem/mem.h b/src/kernel/mem/mem.h index b6e9622..cb9c396 100644 --- a/src/kernel/mem/mem.h +++ b/src/kernel/mem/mem.h @@ -5,6 +5,7 @@ kmalloc_page and kfree_page are used mostly for paging. */ #include <types.h> +#include "_dlmalloc.h" void* kmalloc_page(size_t *phys); void kfree_page(void* page); diff --git a/src/kernel/mem/paging.c b/src/kernel/mem/paging.c index 5953fc6..0527f06 100644 --- a/src/kernel/mem/paging.c +++ b/src/kernel/mem/paging.c @@ -1,6 +1,6 @@ #include "paging.h" #include <bitset.h> -#include <stdlib.h> +#include <stdlib_common.h> #include <core/monitor.h> #include "mem.h" #include "seg.h" @@ -17,7 +17,7 @@ struct page_directory *kernel_pagedir, *current_pagedir; uint32_t frame_alloc() { uint32_t free = bitset_firstFree(&frames); if (free == (uint32_t) -1) { - PANIC("Out of memory!"); + PANIC("No more frames to allocate, system is out of memory!"); } bitset_set(&frames, free); return free; @@ -166,7 +166,6 @@ struct page *pagedir_getPage(struct page_directory *pd, uint32_t address, int ma pd->tablesPhysical[table_idx] |= 0x07; if (table_idx >= FIRST_KERNEL_PAGETABLE) { - monitor_write("UKPI "); tasking_updateKernelPagetable(table_idx, pd->tables[table_idx], pd->tablesPhysical[table_idx]); } |