import less(1)
[unleashed/tickless.git] / share / man / man2 / nice.2
blob15b98be8f09417d94dc8b779617aeb3ab9a58493
1 '\" te
2 .\" Copyright 1989 AT&T.  Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.  Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions 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.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH NICE 2 "Apr 1, 2004"
11 .SH NAME
12 nice \- change priority of a process
13 .SH SYNOPSIS
14 .LP
15 .nf
16 #include <unistd.h>
18 \fBint\fR \fBnice\fR(\fBint\fR \fIincr\fR);
19 .fi
21 .SH DESCRIPTION
22 .sp
23 .LP
24 The \fBnice()\fR function allows a process to change its priority.  The
25 invoking  process must be in a scheduling class that supports the \fBnice()\fR.
26 .sp
27 .LP
28 The \fBnice()\fR function adds the value of  \fIincr\fR to the nice value of
29 the calling process. A process's nice value is a non-negative number for which
30 a greater positive value results in lower \fBCPU\fR priority.
31 .sp
32 .LP
33 A maximum nice value of (2 * \fBNZERO\fR) \(mi1 and a minimum nice value of 0
34 are imposed by the system. \fBNZERO\fR is defined in <\fBlimits.h\fR> with a
35 default value of 20. Requests for values above or below these limits result in
36 the nice value being set to the corresponding limit. A nice value of 40 is
37 treated as 39.
38 .sp
39 .LP
40 Calling the \fBnice()\fR function has no effect on the priority of processes or
41 threads with policy \fBSCHED_FIFO\fR or \fBSCHED_RR\fR.
42 .sp
43 .LP
44 Only a process with the {\fBPRIV_PROC_PRIOCNTL\fR} privilege can lower the nice
45 value.
46 .SH RETURN VALUES
47 .sp
48 .LP
49 Upon successful completion, \fBnice()\fR returns the new nice value minus
50 \fBNZERO\fR. Otherwise, \(mi1 is returned, the process's \fInice\fR value is
51 not changed, and \fBerrno\fR is set to indicate the error.
52 .SH ERRORS
53 .sp
54 .LP
55 The \fBnice()\fR function will fail if:
56 .sp
57 .ne 2
58 .na
59 \fB\fBEINVAL\fR\fR
60 .ad
61 .RS 10n
62 The \fBnice()\fR function is called by a process in a scheduling class other
63 than time-sharing or fixed-priority.
64 .RE
66 .sp
67 .ne 2
68 .na
69 \fB\fBEPERM\fR\fR
70 .ad
71 .RS 10n
72 The \fIincr\fR argument is negative or greater than 40 and the
73 {\fBPRIV_PROC_PRIOCNTL\fR} privilege is not asserted in the effective set of
74 the calling process.
75 .RE
77 .SH USAGE
78 .sp
79 .LP
80 The \fBpriocntl\fR(2) function is a more general interface to scheduler
81 functions.
82 .sp
83 .LP
84 Since \(mi1 is a permissible return value in a successful situation, an
85 application wishing to check for error situations should set \fBerrno\fR to 0,
86 then call \fBnice()\fR, and if it returns \fB\(mi1\fR, check to see if
87 \fBerrno\fR is non-zero.
88 .SH ATTRIBUTES
89 .sp
90 .LP
91 See \fBattributes\fR(5) for descriptions of the following attributes:
92 .sp
94 .sp
95 .TS
96 box;
97 c | c
98 l | l .
99 ATTRIBUTE TYPE  ATTRIBUTE VALUE
101 Interface Stability     Standard
103 MT-Level        Async-Signal-Safe
106 .SH SEE ALSO
109 \fBnice\fR(1), \fBexec\fR(2), \fBpriocntl\fR(2), \fBgetpriority\fR(3C),
110 \fBattributes\fR(5), \fBprivileges\fR(5), \fBstandards\fR(5)