Xenomai
3.1
|
Region of memory dedicated to real-time allocation. More...
Data Structures | |
struct | RT_HEAP_INFO |
Heap status descriptor. More... | |
Macros | |
#define | H_PRIO 0x1 /* Pend by task priority order. */ |
Creation flags. More... | |
Functions | |
int | rt_heap_create (RT_HEAP *heap, const char *name, size_t heapsize, int mode) |
Create a heap. More... | |
int | rt_heap_delete (RT_HEAP *heap) |
Delete a heap. More... | |
int | rt_heap_alloc_timed (RT_HEAP *heap, size_t size, const struct timespec *abs_timeout, void **blockp) |
Allocate a block from a heap. More... | |
static int | rt_heap_alloc_until (RT_HEAP *heap, size_t size, RTIME timeout, void **blockp) |
Allocate a block from a heap (with absolute scalar timeout). More... | |
static int | rt_heap_alloc (RT_HEAP *heap, size_t size, RTIME timeout, void **blockp) |
Allocate a block from a heap (with relative scalar timeout). More... | |
int | rt_heap_free (RT_HEAP *heap, void *block) |
Release a block to a heap. More... | |
int | rt_heap_inquire (RT_HEAP *heap, RT_HEAP_INFO *info) |
Query heap status. More... | |
int | rt_heap_bind (RT_HEAP *heap, const char *name, RTIME timeout) |
Bind to a heap. More... | |
int | rt_heap_unbind (RT_HEAP *heap) |
Unbind from a heap. More... | |
Region of memory dedicated to real-time allocation.
Heaps are regions of memory used for dynamic memory allocation in a time-bounded fashion. Blocks of memory are allocated and freed in an arbitrary order and the pattern of allocation and size of blocks is not known until run time.
#define H_PRIO 0x1 /* Pend by task priority order. */ |
Creation flags.
Referenced by rt_heap_create().
|
inlinestatic |
Allocate a block from a heap (with relative scalar timeout).
This routine is a variant of rt_heap_alloc_timed() accepting a relative timeout specification expressed as a scalar value. Passing TM_INFINITE in timeout causes the caller to block indefinitely until a block is available. Passing TM_NONBLOCK causes the service to return immediately without blocking in case a block is not available.
int rt_heap_alloc_timed | ( | RT_HEAP * | heap, |
size_t | size, | ||
const struct timespec * | abs_timeout, | ||
void ** | blockp | ||
) |
Allocate a block from a heap.
This service allocates a block from a given heap, or returns the address of the single memory segment if H_SINGLE was mentioned in the creation mode to rt_heap_create(). When not enough memory is available on entry to this service, tasks may be blocked until their allocation request can be fulfilled.
heap | The heap descriptor. |
size | The requested size (in bytes) of the block. If the heap is managed as a single-block area (H_SINGLE), this value can be either zero, or the same value given to rt_heap_create(). In that case, the same block covering the entire heap space is returned to all callers of this service. |
abs_timeout | An absolute date expressed in clock ticks, specifying a time limit to wait for a block of the requested size to be available from the heap (see note). Passing NULL causes the caller to block indefinitely until a block is available. Passing { .tv_sec = 0, .tv_nsec = 0 } causes the service to return immediately without blocking in case a block is not available. |
blockp | A pointer to a memory location which will be written upon success with the address of the allocated block, or the start address of the single memory segment. In the former case, the block can be freed using rt_heap_free(). |
|
inlinestatic |
Allocate a block from a heap (with absolute scalar timeout).
This routine is a variant of rt_heap_alloc_timed() accepting an absolute timeout specification expressed as a scalar value. Passing TM_INFINITE in timeout causes the caller to block indefinitely until a block is available. Passing TM_NONBLOCK causes the service to return immediately without blocking in case a block is not available.
int rt_heap_bind | ( | RT_HEAP * | heap, |
const char * | name, | ||
RTIME | timeout | ||
) |
Bind to a heap.
This routine creates a new descriptor to refer to an existing heap identified by its symbolic name. If the object does not exist on entry, the caller may block until a heap of the given name is created.
heap | The address of a heap descriptor filled in by the operation. Contents of this memory is undefined upon failure. |
name | A valid NULL-terminated name which identifies the heap to bind to. This string should match the object name argument passed to rt_heap_create(). |
timeout | The number of clock ticks to wait for the registration to occur (see note). Passing TM_INFINITE causes the caller to block indefinitely until the object is registered. Passing TM_NONBLOCK causes the service to return immediately without waiting if the object is not registered on entry. |
int rt_heap_create | ( | RT_HEAP * | heap, |
const char * | name, | ||
size_t | heapsz, | ||
int | mode | ||
) |
Create a heap.
This routine creates a memory heap suitable for time-bounded allocation requests of RAM chunks. When not enough memory is available, tasks may be blocked until their allocation request can be fulfilled.
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 return the same block address, pointing at the beginning of the heap memory.
heap | The address of a heap descriptor which can be later used to identify uniquely the created object, upon success of this call. |
name | An ASCII string standing for the symbolic name of the heap. When non-NULL and non-empty, a copy of this string is used for indexing the created heap into the object registry. |
heapsz | The size (in bytes) of the memory pool, blocks will be claimed and released to. This area is not extensible, so this value must be compatible with the highest memory pressure that could be expected. The valid range is between 1 byte and 2Gb. |
mode | The heap creation mode. The following flags can be OR'ed into this bitmask, each of them affecting the new heap: |
References H_PRIO.
int rt_heap_delete | ( | RT_HEAP * | heap | ) |
Delete a heap.
This routine deletes a heap object previously created by a call to rt_heap_create(), releasing all tasks currently blocked on it.
heap | The heap descriptor. |
int rt_heap_free | ( | RT_HEAP * | heap, |
void * | block | ||
) |
Release a block to a heap.
This service should be used to release a block to the heap it belongs to. An attempt to fulfill the request of every task blocked on rt_heap_alloc() is made once block is returned to the memory pool.
heap | The heap descriptor. |
block | The address of the block to free. |
int rt_heap_inquire | ( | RT_HEAP * | heap, |
RT_HEAP_INFO * | info | ||
) |
Query heap status.
This routine returns the status information about heap.
heap | The heap descriptor. |
info | A pointer to the return buffer" to copy the information to. |
int rt_heap_unbind | ( | RT_HEAP * | heap | ) |
Unbind from a heap.
heap | The heap descriptor. |
This routine releases a previous binding to a heap. After this call has returned, the descriptor is no more valid for referencing this object.