I am working on thread priorities within my application. There is one realtime thread scheduled with SCHED_RR
. I use pthread_setschedparam
to set this policy and the priority for it. pthread_setschedparam
takes the thread id as a first argument, so after creating a thread with boost::thread
I can set its realtime priority.
However, another thread should have a certain nice-level, but no realtime scheduling. I can use
pid_t tid;
tid = syscall(SYS_gettid);
int ret = setpriority(PRIO_PROCESS, tid, nicelevel);
to set its nice level to ǹicelevel
, but this is working only if I modify the thread function to contain the lines above. Is there a way to set the nice level from the method that creates the thread?
Thanks!