nrelease - fix/improve livecd
[dragonfly.git] / lib / libc / sys / rtprio.2
1 .\" Copyright (c) 1994, Henrik Vestergaard Draboel
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by Henrik Vestergaard Draboel.
15 .\" 4. The name of the author may not be used to endorse or promote products
16 .\"    derived from this software without specific prior written permission.
17 .\"
18 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" SUCH DAMAGE.
29 .\"
30 .\" $FreeBSD: src/lib/libc/sys/rtprio.2,v 1.13.2.9 2001/12/14 18:34:01 ru Exp $
31 .\"
32 .Dd December 14, 2007
33 .Dt RTPRIO 2
34 .Os
35 .Sh NAME
36 .Nm rtprio ,
37 .Nm lwp_rtprio
38 .Nd examine or modify a process/lwp realtime or idle priority
39 .Sh LIBRARY
40 .Lb libc
41 .Sh SYNOPSIS
42 .In sys/types.h
43 .In sys/rtprio.h
44 .Ft int
45 .Fn rtprio "int function" "pid_t pid" "struct rtprio *rtp"
46 .In sys/lwp.h
47 .Ft int
48 .Fn lwp_rtprio "int function" "pid_t pid" "lwpid_t tid" "struct rtprio *rtp"
49 .Sh DESCRIPTION
50 .Fn rtprio
51 is used to lookup or change the realtime or idle priority of a process.
52 .Pp
53 .Fa function
54 specifies the operation to be performed.
55 .Dv RTP_LOOKUP
56 to lookup the current priority, and
57 .Dv RTP_SET
58 to set the priority.
59 .Fa pid
60 specifies the process to be used, 0 for the current process.
61 .Pp
62 .Fa *rtp
63 is a pointer to a
64 .Vt struct rtprio
65 which is used to specify the priority and priority type.
66 This structure has the following form:
67 .Bd -literal
68 struct rtprio {
69         u_short type;
70         u_short prio;
71 };
72 .Ed
73 .Pp
74 The value of the
75 .Nm type
76 field may be
77 .Dv RTP_PRIO_REALTIME
78 for realtime priorities,
79 .Dv RTP_PRIO_NORMAL
80 for normal priorities, and
81 .Dv RTP_PRIO_IDLE
82 for idle priorities.
83 The priority specified by the
84 .Nm prio
85 field ranges between 0 and
86 .Dv RTP_PRIO_MAX
87 (usually 31).
88 0 is the highest possible priority.
89 .Pp
90 Realtime and idle priority is inherited through
91 .Fn fork
92 and
93 .Fn exec .
94 .Pp
95 A realtime process can only be preempted by a process of equal or
96 higher priority, or by an interrupt; idle priority processes will run only
97 when no other real/normal priority process is runnable.
98 Higher real/idle priority processes
99 preempt lower real/idle priority processes.
100 Processes of equal real/idle priority are run round-robin.
101 .Pp
102 The
103 .Fn lwp_rtprio
104 function is the lwp counterpart of
105 .Fn rtprio .
106 It takes one additional argument,
107 .Fa tid ,
108 specifying the lwp to be used, -1 for the current lwp.
109 .Sh RETURN VALUES
110 .Rv -std rtprio lwp_rtprio
111 .Sh ERRORS
112 .Fn rtprio
113 and
114 .Fn lwp_rtprio
115 will fail if
116 .Bl -tag -width Er
117 .It Bq Er EINVAL
118 The specified
119 .Fa prio
120 was out of range.
121 .It Bq Er EPERM
122 The calling process is not allowed to set the realtime priority.
123 Only
124 root is allowed to change the realtime priority of any process, and non-root
125 may only change the idle priority of the current process.
126 .It Bq Er ESRCH
127 The specified process was not found.
128 .El
129 .Sh SEE ALSO
130 .Xr nice 1 ,
131 .Xr ps 1 ,
132 .Xr rtprio 1 ,
133 .Xr setpriority 2 ,
134 .Xr nice 3 ,
135 .Xr renice 8
136 .Sh AUTHORS
137 .An -nosplit
138 The original author was
139 .An Henrik Vestergaard Draboel Aq Mt hvd@terry.ping.dk .
140 This implementation was substantially rewritten by
141 .An David Greenman .