1nice(2) System Calls nice(2)
2
3
4
6 nice - change priority of a process
7
9 #include <unistd.h>
10
11 int nice(int incr);
12
13
15 The nice() function allows a process to change its priority. The
16 invoking process must be in a scheduling class that supports the
17 nice().
18
19
20 The nice() function adds the value of incr to the nice value of the
21 calling process. A process's nice value is a non-negative number for
22 which a greater positive value results in lower CPU priority.
23
24
25 A maximum nice value of (2 * NZERO) −1 and a minimum nice value of 0
26 are imposed by the system. NZERO is defined in <limits.h> with a
27 default value of 20. Requests for values above or below these limits
28 result in the nice value being set to the corresponding limit. A nice
29 value of 40 is treated as 39.
30
31
32 Calling the nice() function has no effect on the priority of processes
33 or threads with policy SCHED_FIFO or SCHED_RR.
34
35
36 Only a process with the {PRIV_PROC_PRIOCNTL} privilege can lower the
37 nice value.
38
40 Upon successful completion, nice() returns the new nice value minus
41 NZERO. Otherwise, −1 is returned, the process's nice value is not
42 changed, and errno is set to indicate the error.
43
45 The nice() function will fail if:
46
47 EINVAL The nice() function is called by a process in a scheduling
48 class other than time-sharing or fixed-priority.
49
50
51 EPERM The incr argument is negative or greater than 40 and the
52 {PRIV_PROC_PRIOCNTL} privilege is not asserted in the effec‐
53 tive set of the calling process.
54
55
57 The priocntl(2) function is a more general interface to scheduler func‐
58 tions.
59
60
61 Since −1 is a permissible return value in a successful situation, an
62 application wishing to check for error situations should set errno to
63 0, then call nice(), and if it returns −1, check to see if errno is
64 non-zero.
65
67 See attributes(5) for descriptions of the following attributes:
68
69
70
71
72 ┌─────────────────────────────┬─────────────────────────────┐
73 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
74 ├─────────────────────────────┼─────────────────────────────┤
75 │Interface Stability │Standard │
76 ├─────────────────────────────┼─────────────────────────────┤
77 │MT-Level │Async-Signal-Safe │
78 └─────────────────────────────┴─────────────────────────────┘
79
81 nice(1), exec(2), priocntl(2), getpriority(3C), attributes(5), privi‐
82 leges(5), standards(5)
83
84
85
86SunOS 5.11 1 Apr 2004 nice(2)