xtos_ rt_ alloc_ locked
Allocates page-aligned memory, locks it, and returns it to the caller.
On this page
Declaration
#include <xtos/rt.h>
void *xtos_rt_alloc_locked(size_t length);Parameters
| Parameter | Type | Description |
|---|---|---|
| length | size_t | Positive byte count; returned memory is uninitialized. |
Return value
Returns a pointer on success, or NULL with errno on failure. The caller must free it with the original pointer and length.
Errors
| errno | Condition |
|---|---|
| EINVAL | length is zero. |
| ENOMEM | Allocation or mlock failed. |
| ENOSYS | sysconf did not return a positive page size. |
| EAGAIN | The underlying mlock could not lock all or part of the range immediately. |
Notes
- The implementation uses posix_memalign and mlock; on failure it frees the block and preserves the failure errno.
- Ownership passes to the caller; clear, touch, and complete other allocations before the high-priority path.
Example
Source
This reference describes headers and implementation at OpenXTOS commit dd313955ad57542bcd2af8827157d1bbd0cf5e83.