xref: /freebsd-12.1/lib/libc/sys/rtprio.2 (revision 578d29dd)
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$
31.\"
32.Dd July 23, 1994
33.Dt RTPRIO 2
34.Sh NAME
35.Nm rtprio
36.Nd examine or modify a process realtime or idle priority
37.Sh SYNOPSIS
38.Fd #include <sys/types.h>
39.Fd #include <sys/rtprio.h>
40.Ft int
41.Fn rtprio "int function" "pid_t pid" "struct rtprio *rtp"
42.Sh DESCRIPTION
43.Fn rtprio
44is used to lookup or change the realtime or idle priority of a process.
45
46.Fa function
47specifies the operation to be performed. RTP_LOOKUP to lookup the current priority,
48and RTP_SET to set the priority.
49.Fa pid
50specifies the process to be used, 0 for the current process.
51
52.Fa *rtp
53is a pointer to a struct rtprio which is used to specify the priority and priority type.
54This structure has the following form:
55.Bd -literal
56struct rtprio {
57	u_short	type;
58	u_short prio;
59};
60.Ed
61.Pp
62The value of the
63.Nm type
64field may be RTP_PRIO_REALTIME for realtime priorities,
65RTP_PRIO_NORMAL for normal priorities, and RTP_PRIO_IDLE for idle priorities.
66The priority specified by the
67.Nm prio
68field ranges between 0 and
69.Dv RTP_PRIO_MAX (usually 31) .
700 is the highest possible priority.
71
72Realtime and idle priority is inherited through fork() and exec().
73
74A realtime process can only be preempted by a process of equal or
75higher priority, or by an interrupt; idle priority processes will run only
76when no other real/normal priority process is runnable. Higher real/idle priority processes
77preempt lower real/idle priority processes. Processes of equal real/idle priority are run round-robin.
78.Sh RETURN VALUES
79.Fn rtprio
80will return 0 for success and -1 for all errors. The global variable
81.Va errno
82will be set to indicate the error.
83.Sh ERRORS
84.Fn rtprio
85will fail if
86.Bl -tag -width Er
87.It Bq Er EINVAL
88The specified
89.Fa prio
90was out of range.
91.It Bq Er EPERM
92The calling process is not allowed to set the realtime priority. Only
93root is allowed to change the realtime priority of any process, and non-root
94may only change the idle priority of the current process.
95.It Bq Er ESRCH
96The specified process was not found.
97.Sh AUTHORS
98The original author was
99.An Henrik Vestergaard Draboel Aq [email protected] .
100This implementation in
101.Fx
102was substantially rewritten by
103.An David Greenman .
104.Sh SEE ALSO
105.Xr nice 1 ,
106.Xr ps 1 ,
107.Xr rtprio 1 ,
108.Xr setpriority 2 ,
109.Xr nice 3 ,
110.Xr renice 8
111