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

xtos_rt_set_affinity

Sets the calling thread’s CPU affinity mask to one logical CPU.

On this page

Declaration

c
#include <xtos/rt.h>

int xtos_rt_set_affinity(int cpu);

Parameters

ParameterTypeDescription
cpuintLogical CPU ID, from 0 through CPU_SETSIZE-1; XTOS_RT_NO_CPU is not accepted here.

Return value

Returns 0 on success and -1 on failure.

Errors

errnoCondition
EINVALcpu is negative or not below CPU_SETSIZE, or the kernel rejects the CPU set.
EPERMThe thread is not permitted to change its affinity or use the target CPU set.
system errnoPreserves errno from sched_setaffinity.

Notes

  • cpu is a system logical ID, not an index in an allowed-CPU list; the kernel decides whether it is online and allowed.
  • The function allocates no memory, retains no caller data, and affects only the calling thread.

Example

Source

This reference describes headers and implementation at OpenXTOS commit dd313955ad57542bcd2af8827157d1bbd0cf5e83.