Add a kmalloc lock. This definitely reduces flakiness.

This commit is contained in:
Andreas Kling 2018-10-24 00:51:19 +02:00
parent 8e27cf2428
commit 82dae8fc90
Notes: sideshowbarker 2024-07-19 18:39:39 +09:00
2 changed files with 13 additions and 0 deletions

View File

@ -33,6 +33,11 @@ public:
m_lock = 0;
}
void init()
{
m_lock = 0;
}
private:
volatile dword m_lock { 0 };
};

View File

@ -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