next up previous contents index
Next: 9.5.18 mem_unlock: Unlock access Up: 9.5 Memory Allocation Previous: 9.5.16 morecore: add memory

9.5.17 mem_lock: Lock access to malloc memory pool

   

SYNOPSIS

#include <oskit/c/malloc.h>

void mem_lock(void);

DESCRIPTION

This routine is called from any default memory allocation routine before it attempts to access malloc_lmm.

Coupled with mem_unlock, this provides a way to make memory allocation thread and MP safe. In a multithreaded client OS, these functions will use the default lock implementation as provided by the lock manager (see Section 4.12), to protect accesses to the malloc_lmm. Or, these functions may be overridden with a suitable synchronization primitive.

Note that the kernel support library provides defaults for mem_lock and mem_unlock that call base_critical_enter and base_critical_leave respectively. However, you'll only get these versions if you use the kernel support library and link it in before the minimal C library.



University of Utah Flux Research Group