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
#include <xtos/rt.h>
int xtos_rt_apply(const struct xtos_rt_config *config);Parameters
| Parameter | Type | Description |
|---|---|---|
| config | const 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
| errno | Condition |
|---|---|
| EINVAL | config is NULL, scheduler arguments are invalid, or cpu is neither -1 nor below CPU_SETSIZE. |
| EPERM | The thread lacks permission for the requested policy or system policy rejects the change. |
| system errno | Preserves 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.