System/Setup/Environment+FFI/LibC: Increase calloc/malloc mem_tasks

Give LibC malloc() and calloc() an array of 16 mem_tasks each, for now.
We will probably be removing this, in favor of giving each non-HolyC
library its own static memory pool, as we will do with stb_truetype.h in
a forthcoming commit.
This commit is contained in:
Alec Murphy 2025-04-19 20:33:30 -04:00
parent b7cab3b419
commit b40820272f
2 changed files with 20 additions and 4 deletions

View file

@ -12,8 +12,8 @@ U0 bcmp()
U64 @calloc(I64 size) U64 @calloc(I64 size)
{ {
U64 res = CAlloc(size, malloc_mem_task[malloc_current_mem_task % MALLOC_MEM_TASK_COUNT]->code_heap); U64 res = CAlloc(size, calloc_mem_task[calloc_current_mem_task % CALLOC_MEM_TASK_COUNT]->code_heap);
malloc_current_mem_task++; calloc_current_mem_task++;
return res; return res;
} }

View file

@ -169,8 +169,8 @@ sys_code_bp->mem_free_lst = ShrinkMemBlkByPags(sys_code_bp->mem_free_lst, 131072
CTask* erythros_mem_task = Spawn(&@erythros_mem_task_loop, , "ErythrosMemTask"); CTask* erythros_mem_task = Spawn(&@erythros_mem_task_loop, , "ErythrosMemTask");
#define MALLOC_MEM_TASK_COUNT 4 #define MALLOC_MEM_TASK_COUNT 16
CTask** malloc_mem_task = CAlloc(sizeof(CTask*) * MALLOC_MEM_TASK_COUNT, erythros_mem_task); CTask** malloc_mem_task = CAlloc(sizeof(CTask*) * MALLOC_MEM_TASK_COUNT, adam_task);
I64 malloc_current_mem_task = 0; I64 malloc_current_mem_task = 0;
U0 @malloc_mem_tasks_init() U0 @malloc_mem_tasks_init()
@ -185,6 +185,22 @@ U0 @malloc_mem_tasks_init()
@malloc_mem_tasks_init; @malloc_mem_tasks_init;
#define CALLOC_MEM_TASK_COUNT 16
CTask** calloc_mem_task = CAlloc(sizeof(CTask*) * CALLOC_MEM_TASK_COUNT, adam_task);
I64 calloc_current_mem_task = 0;
U0 @calloc_mem_tasks_init()
{
U8* scratch_buffer[64];
I64 i;
for (i = 0; i < CALLOC_MEM_TASK_COUNT; i++) {
StrPrint(scratch_buffer, "ErythrosCallocTask%d", i);
calloc_mem_task[i] = Spawn(&@erythros_mem_task_loop, , scratch_buffer);
}
}
@calloc_mem_tasks_init;
U0 dd() { DocDump(adam_task->put_doc); } U0 dd() { DocDump(adam_task->put_doc); }
//@patch_jmp_rel32(&Fault2, &Reboot); // Reboot instead of crashing to the debugger //@patch_jmp_rel32(&Fault2, &Reboot); // Reboot instead of crashing to the debugger
U0 NoBeep(I8, Bool) {}; U0 NoBeep(I8, Bool) {};