| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- change priority of a process
#include <unistd.h>intnice(intincr);
Thenice() function allows a process to change its priority. The invoking process must be in a scheduling class that supports thenice().
Thenice() function adds the value ofincr to the nicevalue of the calling process. A process's nice value is a non-negativenumber for which a greater positive value results in lower CPU priority.
A maximum nice value of (2 *NZERO) -1 and a minimumnice value of 0 are imposed by the system.NZERO is definedin <limits.h> with a default value of 20. Requests for values aboveor below these limits result in the nice value being set to thecorresponding limit. A nice value of 40 is treated as 39.
Calling thenice() function has no effect on the priority of processesor threads with policySCHED_FIFO orSCHED_RR.
Only a process with the {PRIV_PROC_PRIOCNTL} privilege can lower the nice value.
Upon successful completion,nice() returns the new nice value minusNZERO. Otherwise,-1 is returned, the process'snice value is not changed, anderrnois set to indicate the error.
Thenice() function will fail if:
Thenice() function is called by a process in a scheduling class other than time-sharing or fixed-priority.
Theincr argument is negative or greater than 40 and the {PRIV_PROC_PRIOCNTL} privilege is not asserted in the effective set of the calling process.
Thepriocntl(2) function is a more general interface to scheduler functions.
Since -1 is a permissible return value in a successful situation, anapplication wishing to check for error situations should seterrno to 0,then callnice(), and if it returns-1, check to see iferrno is non-zero.
Seeattributes(5) for descriptions of the following attributes:
|
nice(1),exec(2),priocntl(2),getpriority(3C),attributes(5),privileges(5),standards(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |