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

xtos_rt_apply

Sets the Linux scheduler for the calling thread and, unless config.cpu is XTOS_RT_NO_CPU, binds it to one CPU.

On this page

Declaration

c
#include <xtos/rt.h>

int xtos_rt_apply(const struct xtos_rt_config *config);

Parameters

ParameterTypeDescription
configconst struct xtos_rt_config *Non-NULL and caller-owned; fields are policy, priority, and cpu. cpu=-1 only means that apply skips affinity.

Return value

Returns 0 on success and -1 on failure. Scheduling is applied before affinity.

Errors

errnoCondition
EINVALconfig is NULL, scheduler arguments are invalid, or cpu is neither -1 nor below CPU_SETSIZE.
EPERMThe thread lacks permission for the requested policy or system policy rejects the change.
system errnoPreserves errno from the underlying sched_setscheduler or sched_setaffinity call.

Notes

  • config is read only during the call; the SDK retains no pointer and changes only the calling thread.
  • A failed affinity step does not roll back a scheduler change that already succeeded. The function does not allocate heap memory.

Example

Source

This reference describes headers and implementation at OpenXTOS commit dd313955ad57542bcd2af8827157d1bbd0cf5e83.