Merge branch 'vendor/TNFTP'
[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 .\" $DragonFly: src/lib/libc/sys/rtprio.2,v 1.6 2007/12/14 23:12:55 swildner Exp $
32 .\"
33 .Dd December 14, 2007
34 .Dt RTPRIO 2
35 .Os
36 .Sh NAME
37 .Nm rtprio ,
38 .Nm lwp_rtprio
39 .Nd examine or modify a process/lwp realtime or idle priority
40 .Sh LIBRARY
41 .Lb libc
42 .Sh SYNOPSIS
43 .In sys/types.h
44 .In sys/rtprio.h
45 .Ft int
46 .Fn rtprio "int function" "pid_t pid" "struct rtprio *rtp"
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 (usually 31) .
87 0 is the highest possible priority.
88 .Pp
89 Realtime and idle priority is inherited through
90 .Fn fork
91 and
92 .Fn exec .
93 .Pp
94 A realtime process can only be preempted by a process of equal or
95 higher priority, or by an interrupt; idle priority processes will run only
96 when no other real/normal priority process is runnable.
97 Higher real/idle priority processes
98 preempt lower real/idle priority processes.
99 Processes of equal real/idle priority are run round-robin.
100 .Pp
101 The
102 .Fn lwp_rtprio
103 function is the lwp counterpart of
104 .Fn rtprio .
105 It takes one additional argument,
106 .Fa tid ,
107 specifying the lwp to be used, -1 for the current lwp.
108 .Sh RETURN VALUES
109 .Rv -std rtprio lwp_rtprio
110 .Sh ERRORS
111 .Fn rtprio
112 and
113 .Fn lwp_rtprio
114 will fail if
115 .Bl -tag -width Er
116 .It Bq Er EINVAL
117 The specified
118 .Fa prio
119 was out of range.
120 .It Bq Er EPERM
121 The calling process is not allowed to set the realtime priority.
122 Only
123 root is allowed to change the realtime priority of any process, and non-root
124 may only change the idle priority of the current process.
125 .It Bq Er ESRCH
126 The specified process was not found.
127 .El
128 .Sh SEE ALSO
129 .Xr nice 1 ,
130 .Xr ps 1 ,
131 .Xr rtprio 1 ,
132 .Xr setpriority 2 ,
133 .Xr nice 3 ,
134 .Xr renice 8
135 .Sh AUTHORS
136 .An -nosplit
137 The original author was
138 .An Henrik Vestergaard Draboel Aq hvd@terry.ping.dk .
139 This implementation was substantially rewritten by
140 .An David Greenman .