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

xtos_rt_lock_memory

Locks an existing caller-owned user-memory range through mlock.

On this page

Declaration

c
#include <xtos/rt.h>

int xtos_rt_lock_memory(void *address, size_t length);

Parameters

ParameterTypeDescription
addressvoid *Start of the range to lock; must not be NULL. The caller remains responsible for allocation and release.
lengthsize_tByte count, greater than zero; it is not an element count.

Return value

Returns 0 on success and -1 on failure. The SDK does not take ownership of the address.

Errors

errnoCondition
EINVALaddress is NULL or length is zero.
ENOMEMThe range is unmapped or the locked-memory resource limit is insufficient.
EPERMThe process lacks the permission required to lock memory.
EAGAINThe range could not be locked immediately; this errno may be returned by the underlying mlock.

Notes

  • mlock is constrained by RLIMIT_MEMLOCK and permissions; success does not lock the process or future allocations.
  • The call does not allocate, free, or initialize memory and does not guarantee zero page faults or a real-time deadline.

Example

Source

This reference describes headers and implementation at OpenXTOS commit dd313955ad57542bcd2af8827157d1bbd0cf5e83.