I am trying to use ioprio_set to give a calling thread a higher priority for the IO scheduler. This is done within a c++ program. I want the call to look like this:
ioprio_set(IOPRIO_WHO_PROCESS, 0, IOPRIO_PRIO_VALUE(IO_PRIO_CLASS_BE,0));
The man page says ioprio_set does not have Glibc wrapper, so they should be called using syscall. I tried the following:
syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, 0, IOPRIO_PRIO_VALUE(IO_PRIO_CLASS_BE,0));
The problem is that the macros IOPRIO_WHO_PROCESS, IOPRIO_PRIO_VALUE and IO_PRIO_CLASS_BE cannot be found, and I don't know how to replace them by int values.
Thanks for any advice!
Not sure if there's a better way than copying the definitions from include/linux/ioprio.h
#include <sys/syscalls.h>
#define IOPRIO_CLASS_SHIFT (13)
#define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data)
enum {
IOPRIO_WHO_PROCESS = 1,
IOPRIO_WHO_PGRP,
IOPRIO_WHO_USER,
};
int main() {
syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, 0, IOPRIO_PRIO_VALUE(1, 0))
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With