add .Mt to man pages in lib/
[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 .Ft int
47 .Fn lwp_rtprio "int function" "pid_t pid" "lwpid_t tid" "struct rtprio *rtp"
48 .Sh DESCRIPTION
49 .Fn rtprio
50 is used to lookup or change the realtime or idle priority of a process.
51 .Pp
52 .Fa function
53 specifies the operation to be performed.
54 .Dv RTP_LOOKUP
55 to lookup the current priority, and
56 .Dv RTP_SET
57 to set the priority.
58 .Fa pid
59 specifies the process to be used, 0 for the current process.
60 .Pp
61 .Fa *rtp
62 is a pointer to a
63 .Vt struct rtprio
64 which is used to specify the priority and priority type.
65 This structure has the following form:
66 .Bd -literal
67 struct rtprio {
68         u_short type;
69         u_short prio;
70 };
71 .Ed
72 .Pp
73 The value of the
74 .Nm type
75 field may be
76 .Dv RTP_PRIO_REALTIME
77 for realtime priorities,
78 .Dv RTP_PRIO_NORMAL
79 for normal priorities, and
80 .Dv RTP_PRIO_IDLE
81 for idle priorities.
82 The priority specified by the
83 .Nm prio
84 field ranges between 0 and
85 .Dv RTP_PRIO_MAX (usually 31) .
86 0 is the highest possible priority.
87 .Pp
88 Realtime and idle priority is inherited through
89 .Fn fork
90 and
91 .Fn exec .
92 .Pp
93 A realtime process can only be preempted by a process of equal or
94 higher priority, or by an interrupt; idle priority processes will run only
95 when no other real/normal priority process is runnable.
96 Higher real/idle priority processes
97 preempt lower real/idle priority processes.
98 Processes of equal real/idle priority are run round-robin.
99 .Pp
100 The
101 .Fn lwp_rtprio
102 function is the lwp counterpart of
103 .Fn rtprio .
104 It takes one additional argument,
105 .Fa tid ,
106 specifying the lwp to be used, -1 for the current lwp.
107 .Sh RETURN VALUES
108 .Rv -std rtprio lwp_rtprio
109 .Sh ERRORS
110 .Fn rtprio
111 and
112 .Fn lwp_rtprio
113 will fail if
114 .Bl -tag -width Er
115 .It Bq Er EINVAL
116 The specified
117 .Fa prio
118 was out of range.
119 .It Bq Er EPERM
120 The calling process is not allowed to set the realtime priority.
121 Only
122 root is allowed to change the realtime priority of any process, and non-root
123 may only change the idle priority of the current process.
124 .It Bq Er ESRCH
125 The specified process was not found.
126 .El
127 .Sh SEE ALSO
128 .Xr nice 1 ,
129 .Xr ps 1 ,
130 .Xr rtprio 1 ,
131 .Xr setpriority 2 ,
132 .Xr nice 3 ,
133 .Xr renice 8
134 .Sh AUTHORS
135 .An -nosplit
136 The original author was
137 .An Henrik Vestergaard Draboel Aq Mt hvd@terry.ping.dk .
138 This implementation was substantially rewritten by
139 .An David Greenman .