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.
RTAI memory heaps are built over Xenomai'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 RTAI 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 shared memory 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) |
Bind to a shared heap. | |
int | rt_heap_unbind (RT_HEAP *heap) |
Unbind from a shared heap. |
|
Allocate a block or return the shared memory base. This service allocates a block from the heap's internal pool, or return the address of the shared memory segment in the caller's address space if the heap is shared. 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 shared heaps never start the rescheduling procedure.
|
|
Bind to a shared heap. This user-space only service retrieves the ubiquitous descriptor of a given shared RTAI 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.
Environments: This service can be called from:
Rescheduling: always unless the request is immediately satisfied. |
|
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 space, or shared between kernel and user-space. In their simplest form, heaps are only accessible from kernel space, and are merely usable as regular memory allocators. In the shared case, heaps are used as shared memory segments. All allocation requests made through rt_heap_alloc() will then return the same memory block, which will point at to the beginning of the heap memory, and cover the entire heap space. This operating mode is specified by passing the H_SHARED flag into the mode parameter. By the 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 shared (i.e. H_SHARED 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 shared 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 shared heap memory to the caller's address space.
Rescheduling: never. |