xtos_ rt_ get_ current
读取当前线程的 Linux 调度策略和静态优先级。
本页目录
声明
#include <xtos/rt.h>
int xtos_rt_get_current(int *policy, int *priority);参数
| 参数 | 类型 | 说明 |
|---|---|---|
| policy | int * | 非 NULL 输出指针;调用方提供存储。 |
| priority | int * | 非 NULL 输出指针;调用方提供存储。 |
返回值
成功返回 0 并写入两个输出;失败返回 -1。
错误
| errno | 条件 |
|---|---|
| EINVAL | policy 或 priority 为 NULL。 |
| system errno | sched_getscheduler 或 sched_getparam 失败时返回底层 errno。 |
注意事项
- 只读取调用线程,不读取或返回 CPU 亲和性;需要另行使用 sched_getaffinity。
- 输出存储由调用方拥有;失败时不要使用未完整写入的结果。
示例
源码
本文按 OpenXTOS 提交 dd313955ad57542bcd2af8827157d1bbd0cf5e83 的头文件和实现编写。