Svante Signell, on Thu 01 Sep 2016 12:44:04 +0200, wrote: > 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??)
These are just defaults, they could be changed to do -20, but POSIX doesn't require that, so we don't need to care. > 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. So that's the issue. > 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? They aren't created differently. For mach, being root means having a right on the privileged host port. Check how it is done in glibc's sysdeps/mach/hurd/mlock.c and gnumach's vm/vm_user.c which checks for ip_kotype(port) == IKOT_HOST_PRIV. So the idea could be that we add to gnumach an RPC which additionally takes a host port, and can thus check whether it's privileged or not. Samuel