Expanded discussion of relationship between user and kernel

representations of the nice value.
Added mention of RLIMIT_NICE and a cross reference to getrlimit.2 
under the description of the EACCES error.
This commit is contained in:
Michael Kerrisk 2005-07-28 13:21:39 +00:00
parent 7d5b6eb812
commit d818502d25
1 changed files with 26 additions and 7 deletions

View File

@ -134,12 +134,21 @@ may fail if:
.B EPERM
A process was located, but its effective user ID did not match
either the effective or the real user ID of the caller,
and (on Linux systems) the caller did not have the
and was not privileged (on Linux: did not have the
.B CAP_SYS_NICE
capability.
capability).
.TP
.B EACCES
A non superuser attempted to lower a process priority.
The caller attempted to lower a process priority, but did not
have the required privilege (on Linux: did not have the
.B CAP_SYS_NICE
capability).
Since Linux 2.6.12, this error only occurs if the caller attempts
to set a process priority outside the range of its
.B RLIMIT_NICE
resource limit; see
.BR getrlimit (2)
for details.
.SH NOTES
The details on the condition for EPERM depend on the system.
The above description is what SUSv3 says, and seems to be followed on
@ -152,10 +161,20 @@ the effective user ID of the caller to match
the real or effective user ID of the process \fIwho\fP.
.LP
The actual priority range varies between kernel versions.
Linux before 1.3.36 had \-infinity..15. Linux since 1.3.43 has \-20..19,
and the system call getpriority returns 40..1 for these values
(since negative numbers are error codes).
The library call converts N into 20\-N.
Linux before 1.3.36 had \-infinity..15.
Since kerenl 1.3.43 Linux has the range \-20..19.
Within the kernel, nice values are actually represented
using the corresponding range 40..1
(since negative numbers are error codes) and these are the values
employed by the
.B setpriority
and
.B getpriority
system calls.
The glibc wrapper functions for these system calls handle the
translations between the user-land and kernel representations
of the nice value according to the formula
.IR "unice\ =\ 20\ \-\ knice" .
.LP
On some systems, the range of nice values is \-20..20.
.LP