34 struct sched_param param;
36 pthread_getschedparam(pthread_self(), &policy, ¶m);
37 printf(
"Current schedparam: policy %d, prio %d\n", policy, param.sched_priority);
40 int sched = SCHED_FIFO;
41 int min = sched_get_priority_min(sched);
42 int max = sched_get_priority_max(sched);
43 param.sched_priority = prio;
44 if (prio > max || prio < min) {
45 printf(
"Requested prio %d outside current min/max prios: %d/%d\n", prio, min, max);
47 param.sched_priority = max;
49 param.sched_priority = min;
53 if (pthread_setschedparam(pthread_self(), sched, ¶m)) {
54 perror(
"setschedparam failed!");
58 pthread_getschedparam(pthread_self(), &policy, ¶m);
59 printf(
"New schedparam: policy %d, prio %d\n", policy, param.sched_priority);
65 #include <sys/resource.h>
67 #include <sys/syscall.h>
72 tid = syscall(SYS_gettid);
74 return setpriority(PRIO_PROCESS, tid, level);
static int get_rt_prio(int prio)
static int set_nice_level(int level)