aboutsummaryrefslogtreecommitdiffstats
path: root/man-pages-posix-2003/man3p/nice.3p
blob: 2fe455ba2ccaf75eb3a75a0491374774ce5c1a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "NICE" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" nice 
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.SH NAME
nice \- change the nice value of a process
.SH SYNOPSIS
.LP
\fB#include <unistd.h>
.br
.sp
int nice(int\fP \fIincr\fP\fB); \fP
\fB
.br
\fP
.SH DESCRIPTION
.LP
The \fInice\fP() function shall add the value of \fIincr\fP to the
nice value of the calling process. A process' nice value is
a non-negative number for which a more positive value shall result
in less favorable scheduling.
.LP
A maximum nice value of 2*{NZERO}-1 and a minimum nice value of 0
shall be imposed by the system. Requests for values above or
below these limits shall result in the nice value being set to the
corresponding limit. Only a process with appropriate privileges
can lower the nice value.
.LP
Calling the \fInice\fP() function has no effect on the priority of
processes or threads with policy SCHED_FIFO or SCHED_RR. The
effect on processes or threads with other scheduling policies is implementation-defined.
.LP
The nice value set with \fInice\fP() shall be applied to the process.
If the process is multi-threaded, the nice value shall
affect all system scope threads in the process.
.LP
As -1 is a permissible return value in a successful situation, an
application wishing to check for error situations should set
\fIerrno\fP to 0, then call \fInice\fP(), and if it returns -1, check
to see whether \fIerrno\fP is non-zero.
.SH RETURN VALUE
.LP
Upon successful completion, \fInice\fP() shall return the new nice
value -{NZERO}. Otherwise, -1 shall be returned, the
process' nice value shall not be changed, and \fIerrno\fP shall be
set to indicate the error.
.SH ERRORS
.LP
The \fInice\fP() function shall fail if:
.TP 7
.B EPERM
The \fIincr\fP argument is negative and the calling process does not
have appropriate privileges.
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.SS Changing the Nice Value
.LP
The following example adds the value of the \fIincr\fP argument, -20,
to the nice value of the calling process.
.sp
.RS
.nf

\fB#include <unistd.h>
\&...
int incr = -20;
int ret;
.sp

ret = nice(incr);
\fP
.fi
.RE
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIgetpriority\fP(), \fIsetpriority\fP(), the Base Definitions
volume of IEEE\ Std\ 1003.1-2001, \fI<limits.h>\fP, \fI<unistd.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .