xtos_ rt_ set_ affinity
Sets the calling thread’s CPU affinity mask to one logical CPU.
On this page
Declaration
#include <xtos/rt.h>
int xtos_rt_set_affinity(int cpu);Parameters
| Parameter | Type | Description |
|---|---|---|
| cpu | int | Logical 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
| errno | Condition |
|---|---|
| EINVAL | cpu is negative or not below CPU_SETSIZE, or the kernel rejects the CPU set. |
| EPERM | The thread is not permitted to change its affinity or use the target CPU set. |
| system errno | Preserves 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.