1NICE(P) POSIX Programmer's Manual NICE(P)
2
3
4
6 nice - change the nice value of a process
7
9 #include <unistd.h>
10
11 int nice(int incr);
12
13
15 The nice() function shall add the value of incr to the nice value of
16 the calling process. A process' nice value is a non-negative number for
17 which a more positive value shall result in less favorable scheduling.
18
19 A maximum nice value of 2*{NZERO}-1 and a minimum nice value of 0 shall
20 be imposed by the system. Requests for values above or below these lim‐
21 its shall result in the nice value being set to the corresponding
22 limit. Only a process with appropriate privileges can lower the nice
23 value.
24
25 Calling the nice() function has no effect on the priority of processes
26 or threads with policy SCHED_FIFO or SCHED_RR. The effect on processes
27 or threads with other scheduling policies is implementation-defined.
28
29 The nice value set with nice() shall be applied to the process. If the
30 process is multi-threaded, the nice value shall affect all system scope
31 threads in the process.
32
33 As -1 is a permissible return value in a successful situation, an
34 application wishing to check for error situations should set errno to
35 0, then call nice(), and if it returns -1, check to see whether errno
36 is non-zero.
37
39 Upon successful completion, nice() shall return the new nice value
40 -{NZERO}. Otherwise, -1 shall be returned, the process' nice value
41 shall not be changed, and errno shall be set to indicate the error.
42
44 The nice() function shall fail if:
45
46 EPERM The incr argument is negative and the calling process does not
47 have appropriate privileges.
48
49
50 The following sections are informative.
51
53 Changing the Nice Value
54 The following example adds the value of the incr argument, -20, to the
55 nice value of the calling process.
56
57
58 #include <unistd.h>
59 ...
60 int incr = -20;
61 int ret;
62
63
64 ret = nice(incr);
65
67 None.
68
70 None.
71
73 None.
74
76 getpriority() , setpriority() , the Base Definitions volume of
77 IEEE Std 1003.1-2001, <limits.h>, <unistd.h>
78
80 Portions of this text are reprinted and reproduced in electronic form
81 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
82 -- Portable Operating System Interface (POSIX), The Open Group Base
83 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
84 Electrical and Electronics Engineers, Inc and The Open Group. In the
85 event of any discrepancy between this version and the original IEEE and
86 The Open Group Standard, the original IEEE and The Open Group Standard
87 is the referee document. The original Standard can be obtained online
88 at http://www.opengroup.org/unix/online.html .
89
90
91
92IEEE/The Open Group 2003 NICE(P)