Changes between Initial Version and Version 1 of kernel_malloc


Ignore:
Timestamp:
Dec 7, 2014, 7:25:00 PM (10 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • kernel_malloc

    v1 v1  
     1= GIET-VM / Kernel Malloc functions =
     2
     3[[PageOutline]]
     4
     5The [source:soft/giet_vm/giet_common/kernel_malloc.c kernel_malloc.c] and [source:soft/giet_vm/giet_common/kernel_malloc.h kernel_malloc.h] files define the functions used by the kernel to dynamically allocate virtual memory from the kernel heaps distributed in each cluster.
     6
     7== Distributed heaps ==
     8
     9The '''kernel_heap[x][y]''' descriptors array is stored in the kernel_data segment in cluster[0][0]. Each entry [x][y] contains a heap descriptor (kernel_heap_t), defining the current heap state in cluster[x][y].
     10 * All kernel_heap[x][y) descriptors must be initialized once by the '''_heap_init()''' function.
     11 * All allocated blocks have a size that is a power of 2, larger or equal to MIN_BLOCK_SIZE (typically 64 bytes), and are aligned.
     12 * The memory allocation is done by the '''_remote_malloc()''' function, and there is no free mechanism.
     13 * Concurrent dynamic allocation is possible, as each kernel_heap[x][y] descriptor is protected by a specific queuing spin-lock.
     14
     15== access functions ==
     16
     17=== void '''_heap_init'''( ) ===
     18This function initialises the kernel_heap[x][y] descriptors array
     19 * It must exist one heap vseg in each cluster. The vseg length must be a power of 2, and the vseg base address must be aligned.
     20
     21=== void* '''_remote_malloc'''( unsigned int size, unsigned int x, unsigned int y ) ===
     22This function uses and updates the '''kernel_heap[x][y] array, and returns a pointer (virtual address) on a physical memory block located in cluster[x][y].
     23 * '''size''' : number of requested bytes
     24 * '''x''' : cluster X coordinate
     25 * '''y''' : cluster Y coordinate
     26The block size required can be any value, but the allocated block can be larger: the actual size is the smallest power of 2 value larger or equal to the requested size. The base address is always aligned.
     27If no block satisfying the request is available it returns a NULL pointer.
     28