Can't change priority via sys_sched_setscheduler()?

From: Malcolm Rowe
Date: Fri Apr 28 2006 - 07:24:37 EST


Sorry, this is probably a silly question, but what's the correct way to
adjust (reduce, in my case) the priority of a SCHED_NORMAL/SCHED_OTHER
pthread?

glibc translates calls to pthread_setschedprio and pthread_setschedparam
into sys_sched_setparam and sys_sched_setscheduler respectively, which
both end up at sched_setscheduler(), which does:

/*
* Valid priorities for SCHED_FIFO and SCHED_RR are
* 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL and
* SCHED_BATCH is 0.
*/
if (param->sched_priority < 0 ||
(p->mm && param->sched_priority > MAX_USER_RT_PRIO-1) ||
(!p->mm && param->sched_priority > MAX_RT_PRIO-1))
return -EINVAL;
if ((policy == SCHED_NORMAL || policy == SCHED_BATCH)
!= (param->sched_priority == 0))
return -EINVAL;

So calls to (for example)
struct sched_param sp = {9};
pthread_setschedparam(scthread, SCHED_OTHER, &sp);

Will fail with EINVAL. Yet calls to setpriority(PRIO_PROCESS, 0, 9)
within the thread will work as expected.

I suspect I'm missing something - what is it?

Thanks,
Malcolm
(please cc: me, I'm not subscribed)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/