diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-24 00:51:19 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-24 00:51:19 +0200 |
commit | 82dae8fc9052bdee9908dc464f570da8945b71cb (patch) | |
tree | 01f460806a9da2e36178e27055cabdd2c4438d01 /Kernel/kmalloc.cpp | |
parent | 8e27cf2428246d5da26f5a3d05e1398518daf415 (diff) | |
download | serenity-82dae8fc9052bdee9908dc464f570da8945b71cb.zip |
Add a kmalloc lock. This definitely reduces flakiness.
Diffstat (limited to 'Kernel/kmalloc.cpp')
-rw-r--r-- | Kernel/kmalloc.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/kmalloc.cpp b/Kernel/kmalloc.cpp index 09982e2e47..b142a3f60e 100644 --- a/Kernel/kmalloc.cpp +++ b/Kernel/kmalloc.cpp @@ -10,6 +10,7 @@ #include "VGA.h" #include "system.h" #include "Assertions.h" +#include <AK/Lock.h> #define SANITIZE_KMALLOC @@ -29,9 +30,12 @@ PRIVATE BYTE alloc_map[POOL_SIZE / CHUNK_SIZE / 8]; DWORD sum_alloc = 0; DWORD sum_free = POOL_SIZE; +static SpinLock s_kmallocLock; + PUBLIC void kmalloc_init() { + s_kmallocLock.init(); memset( &alloc_map, 0, sizeof(alloc_map) ); memset( (void *)BASE_PHYS, 0, POOL_SIZE ); @@ -42,6 +46,8 @@ kmalloc_init() PUBLIC void * kmalloc( DWORD size ) { + Locker locker(s_kmallocLock); + DWORD chunks_needed, chunks_here, first_chunk; DWORD real_size; DWORD i, j, k; @@ -117,6 +123,8 @@ kfree( void *ptr ) if( !ptr ) return; + Locker locker(s_kmallocLock); + allocation_t *a = (allocation_t *)((((BYTE *)ptr) - sizeof(allocation_t))); #if 0 |