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