wiki:library_malloc

Version 5 (modified by alain, 11 years ago) (diff)

--

The Malloc Library

The malloc.c and malloc.h define an user-level memory allocation service. The requested memory blocks are allocated from the application heap.

If the target architecture is clusterized (one physical memory bank per cluster), the application heap is physically distributed, and it can exist one heap(x,y) segment per cluster, This means one allocator per cluster.

The distributed heap(x,y) segments must be explicitely defined in the application mapping.

The malloc() and free() functions below have the same semantic as the standard UNIX functions. The remote_malloc() and malloc_aligned() functions are GIET-VM extensions.

cluster selection

Using the (x,y) arguments (as in the remote_malloc() function below), the user application can explicitely select the allocator in cluster(x,y). If these arguments (x,y) are not defined, (as in the malloc() function below), the cluster is implicitely defined by the (x,y) coordinate of the processor running the calling task. If there is no heap(x,y) defined in the selected cluster, or if there is no more space in the selected heap(x,y) segment, a NULL pointer is returned.

alignment

Using the align arguments, the user application can require the selected allocator to return a virtual address aligned on a power of 2 (1 << align). If the align argument value is larger than 31, a NULL pointer is returned.

Available functions

  • void * malloc( unsigned int size )
  • void * malloc_aligned( unsigned int size, unsigned int align )
  • void * remote_malloc( unsigned int size, unsigned int x, unsigned int y )
  • void * remote_malloc_aligned( unsigned int size, unsigned int align, unsigned int x, unsigned int y )
  • void free( void* ptr )