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