linux set_bit
Since there is no glibc wrapper for ioprio_set in linux c, we need to call this API with some definition.
由于linux c中没有ioprio_set的glibc包装器,因此我们需要使用一些定义来调用此API。
Using syscall in linux as follows.
在Linux中使用syscall如下。
syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, pid, IOPRIO_PRIO_CLASS(IOPRIO_CLASS_IDLE));
Some other definitions to declare above macros.
上面宏声明的其他一些定义。
69 enum {
70 IOPRIO_CLASS_NONE,
71 IOPRIO_CLASS_RT,
72 IOPRIO_CLASS_BE,
73 IOPRIO_CLASS_IDLE,
74 };
75
76 enum {
77 IOPRIO_WHO_PROCESS = 1,
78 IOPRIO_WHO_PGRP,
79 IOPRIO_WHO_USER,
80 };
65 #define IOPRIO_CLASS_SHIFT (13)
66
67 #define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT)
References:
ioprio.h source
ioprint_set manual
参考文献:
ioprio.h来源
ioprint_set手册
Answered by harryxiyou.
由harryxiyou回答。
翻译自: https://www.systutorials.com/how-to-use-ioprio_set-in-linux-c/
linux set_bit