getpriority(2) — 4 BSD
NAME
getpriority, setpriority − get/set program scheduling priority
SYNOPSIS
#include <sys/resource.h>
nice = getpriority (which, who)
int nice, which, who;
int setpriority (which, who, nice)
int which, who, nice;
DESCRIPTION
The nice value of the process, process group, or user, as indicated by which and who is obtained with the getpriority call and set with the setpriority call. Which is one of
PRIO_PROCESSprocess id
PRIO_PGRPprocess group id
PRIO_USERuser id
and who is interpreted relative to which (a process identifier for PRIO_PROCESS, process group identifier for PRIO_PGRP, and a user ID for PRIO_USER). Nice is a value in the range −20 to 20. The default nice value is 0; lower nice values cause more favorable scheduling. The internal scheduling priority for a process is a function of the specified nice value. An internal scheduling priority of a higher value corresponds to more favorable scheduling.
When the INTERACTIVE_CLASS option is configured in the system, a process whose nice value is between -20 and -16 has a static priority, that is; it does not have its internal scheduling priority altered by the system. A process whose nice value is greater than -16 may have its internal scheduling priority altered by the system.
When the INTERACTIVE_CLASS option is not configured, the internal scheduling priority of a process is never altered. See the CX/RT Reference Manual for more information about scheduling.
Modifying the nice value of a process results in the process’s time quantum (see setquantum(2)) being reset to the system default value corresponding to the new priority value.
The getpriority call returns the highest nice value (lowest numerical value) enjoyed by any of the specified processes. The setpriority call sets the nice values of all of the specified processes to the specified value. Only the super-user or a user with the ACC_SETPRI access vector may lower nice values.
RETURN VALUE
Since getpriority can legitimately return the value −1, it is necessary to clear the external variable errno prior to the call, then check it afterward to determine if a −1 is an error or a legitimate value. The setpriority call returns 0 if there is no error, or −1 if there is.
ERRORS
getpriority and setpriority may return one of the following errors:
[ESRCH] No process(es) were located using the which and who values specified.
[EINVAL] Which was not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER.
In addition to the errors indicated above, setpriority may fail with one of the following errors returned:
[EACCES] A process was located, but neither its effective nor real user ID matched the effective user ID of the caller.
[EACCES] A non super-user attempted to change a process priority to a negative value or the user does not have the ACC_SETPRI access vector. (If access vectors are configured).
SEE ALSO
nice(1), fork(2), setquantum(2), renice(1)
CX/UX Programmer’s Reference Manual