I have a single threaded application. If I use the code below, I get sched_setscheduler(): Operation not permitted .
struct sched_param param; param.sched_priority = 1; if (sched_setscheduler(getpid(), SCHED_RR, ¶m)) printf(stderr, "sched_setscheduler(): %s\n", strerror(errno));
But if I use pthread api, for example, below, I do not get an error. What is the difference between the two for a single-threaded application and is the next function really changing the scheduler and priority, or am I missing some errors?
void assignRRPriority(int tPriority) { int policy; struct sched_param param; pthread_getschedparam(pthread_self(), &policy, ¶m); param.sched_priority = tPriority; if(pthread_setschedparam(pthread_self(), SCHED_RR, ¶m)) printf("error while setting thread priority to %d", tPriority); }
source share