XTOS / OPEN SOURCE REAL-TIME SYSTEMOPEN SOURCE · 1.0.2 · PRERELEASE · IMAGES & 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 in OpenXTOS v1.0.2 (c24e923717670c4724cdaf24c7c105caee8dc2fb).