XTOS / OPEN SOURCE REAL-TIME SYSTEMOPEN SOURCE · VERSION 0.9.0 · BUILD FROM SOURCE
libxtos-rtxtos_rt_alloc_locked

xtos_rt_alloc_locked

Allocates page-aligned memory, locks it, and returns it to the caller.

On this page

Declaration

c
#include <xtos/rt.h>

void *xtos_rt_alloc_locked(size_t length);

Parameters

ParameterTypeDescription
lengthsize_tPositive 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

errnoCondition
EINVALlength is zero.
ENOMEMAllocation or mlock failed.
ENOSYSsysconf did not return a positive page size.
EAGAINThe 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.