On Wed, 2016-08-31 at 14:16 +0200, Samuel Thibault wrote:
> Svante Signell, on Wed 31 Aug 2016 14:10:22 +0200, wrote:
> > 
> > 
> > I would expect values [-20,19] to be OK converted to [5,44] with
> > #define NICE_TO_MACH_PRIORITY(nice) ((nice) + 25) from hurd/hurd/resource.h
> > and 
> > #define invalid_pri(pri) (((pri) < 0) || ((pri) >= NRQS)), where NRQS = 50
> > from kern/sched.h.
> > to work.
> Yes, but see the code changing thread priorities (since that's what is
> posing problem)

Digging a little further shows that tasks and threads are created with
BASEPRI_USER=25 (NICE_TO_MACH_PRIORITY(0)=25). On the other hand kernel threads
has a max priority of BASEPRI_SYSTEM=6 (NICE_TO_MACH_PRIORITY(-19)=6). 
(is -20 not possible as for Linux??)

In the code kern/task.c:task_priority() we have
if (change_threads) {
...
if (thread_priority(thread, priority, TRUE)!= KERN_SUCCESS) ret = KERN_FAILURE;
and in kern/thread.c:thread_priority():
if (priority < thread->max_priority) {ret = KERN_FAILURE;}
irrespective of being root or not. Should code be added to check for root(how)
in task-priority() and call kern/thread.c:thread_max_priority() for all threads
in the task? Or are tasks created by root different in gnumach?

Reply via email to