The implementation of the memory allocator follows the algorithm described in a USENIX 1988 paper called "Design of a General Purpose Memory Allocator for the 4.3BSD Unix Kernel" by Marshall K. McKusick and Michael J. Karels.
Xenomai memory heaps are built over the nucleus's heap objects, which in turn provide the needed support for sharing a memory area between kernel and user-space using direct memory mapping.
Files | |
file | heap.c |
This file is part of the Xenomai project. | |
Functions | |
int | rt_heap_create (RT_HEAP *heap, const char *name, size_t heapsize, int mode) |
Create a memory heap or a shared memory segment. | |
int | rt_heap_delete (RT_HEAP *heap) |
Delete a real-time heap. | |
int | rt_heap_alloc (RT_HEAP *heap, size_t size, RTIME timeout, void **blockp) |
Allocate a block or return the single segment base. | |
int | rt_heap_free (RT_HEAP *heap, void *block) |
Free a block. | |
int | rt_heap_inquire (RT_HEAP *heap, RT_HEAP_INFO *info) |
Inquire about a heap. | |
int | rt_heap_bind (RT_HEAP *heap, const char *name, RTIME timeout) |
Bind to a mappable heap. | |
int | rt_heap_unbind (RT_HEAP *heap) |
Unbind from a mappable heap. |
|
Allocate a block or return the single segment base. This service allocates a block from the heap's internal pool, or returns the address of the single memory segment in the caller's address space. Tasks may wait for some requested amount of memory to become available from local heaps.
Environments: This service can be called from:
Rescheduling: always unless the request is immediately satisfied or timeout specifies a non-blocking operation. Operations on single-block heaps never start the rescheduling procedure.
|
|
Bind to a mappable heap. This user-space only service retrieves the uniform descriptor of a given mappable Xenomai heap identified by its symbolic name. If the heap does not exist on entry, this service blocks the caller until a heap of the given name is created.
This service can be called from:
Rescheduling: always unless the request is immediately satisfied or timeout specifies a non-blocking operation.
|
|
Create a memory heap or a shared memory segment. Initializes a memory heap suitable for time-bounded allocation requests of dynamic memory. Memory heaps can be local to the kernel address space, or mapped to user-space. In their simplest form, heaps are only accessible from kernel space, and are merely usable as regular memory allocators. Heaps existing in kernel space can be mapped by user-space processes to their own address space provided H_MAPPABLE has been passed into the mode parameter. By default, heaps support allocation of multiple blocks of memory in an arbitrary order. However, it is possible to ask for single-block management by passing the H_SINGLE flag into the mode parameter, in which case the entire memory space managed by the heap is made available as a unique block. In this mode, all allocation requests made through rt_heap_alloc() will then return the same block address, pointing at the beginning of the heap memory. H_SHARED is a shorthand for creating shared memory segments transparently accessible from kernel and user-space contexts, which are basically single-block, mappable heaps. By proper use of a common name, all tasks can bind themselves to the same heap and thus share the same memory space, which start address should be subsequently retrieved by a call to rt_heap_alloc().
Environments: This service can be called from:
Rescheduling: possible. |
|
Delete a real-time heap. Destroy a heap and release all the tasks currently pending on it. A heap exists in the system since rt_heap_create() has been called to create it, so this service must be called in order to destroy it afterwards.
Environments: This service can be called from:
Rescheduling: possible. |
|
Free a block. This service releases a block to the heap's internal pool. If some task is currently waiting for a block so that it's pending request could be satisfied as a result of the release, it is immediately resumed. If the heap is defined as a single-block area (i.e. H_SINGLE mode), this service leads to a null-effect and always returns successfully.
This service can be called from:
Rescheduling: possible. |
|
Inquire about a heap. Return various information about the status of a given heap.
Environments: This service can be called from:
Rescheduling: never. |
|
Unbind from a mappable heap. This user-space only service unbinds the calling task from the heap object previously retrieved by a call to rt_heap_bind(). Unbinding from a heap when it is no more needed is especially important in order to properly release the mapping resources used to attach the heap memory to the caller's address space.
Rescheduling: never. |