1.\" 2.\" Copyright (c) 1994, Henrik Vestergaard Draboel 3.\" All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 3. All advertising materials mentioning features or use of this software 14.\" must display the following acknowledgement: 15.\" This product includes software developed by Henrik Vestergaard Draboel. 16.\" 4. The name of the author may not be used to endorse or promote products 17.\" derived from this software without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" $Id: rtprio.1,v 1.1 1994/09/01 12:05:13 davidg Exp $ 32.\" 33.Dd July 23, 1994 34.Dt RTPRIO 1 35.Os 36.Sh NAME 37.Nm rtprio , 38.Nm idprio 39.Nd execute, examine or modify a utilitys or process realtime 40or idletime scheduling priority 41.Sh SYNOPSIS 42 43.Nm [id|rt]prio 44.Nm [id|rt]prio 45.Ar pid 46.Nm [id|rt]prio 47.Ar priority 48.Ar command 49.Op args 50.Nm [id|rt]prio 51.Ar priority 52.Ar -pid 53.Nm [id|rt]prio 54.Ar -t 55.Ar command 56.Op args 57.Nm [id|rt]prio 58.Ar -t 59.Ar -pid 60.Sh DESCRIPTION 61.Nm Rtprio 62is used for controlling realtime process scheduling. 63 64.Nm Idprio 65is used for controlling idletime process scheduling, and can be called 66with the same options as 67.Nm Rtprio . 68 69A process with a realtime priority is not subject to priority 70degradation, and will only be preempted by another process of equal or 71higher realtime priority. 72 73A process with an idle priority will run only when no other 74process is runnable and then only if it's idle priority is equal or 75greater than all other runnable idle priority processes. 76 77.Nm Rtprio 78or 79.Nm Idprio 80when called without arguments will return the realtime priority 81of the current process. 82 83If 84.Nm rtprio 85is called with 1 argument, it will return the realtime priority 86of the process with the specified 87.Ar pid . 88 89If 90.Ar priority 91is specified, the process or program is run at that realtime priority. 92If 93.Ar -t 94is specified, the process or program is run as a normal (non-realtime) 95process. 96 97If 98.Ar -pid 99is specified, the process with the process identifier "pid" will be 100modified, else if 101.Ar command 102is specified, that program is run with its arguments. 103 104.Ar Priority 105is an integer between 0 and RTP_PRIO_MAX (usually 31). 0 is the 106highest priority 107 108.Ar Pid 109of 0 means "the current process". 110 111Only root is allowed to set realtime priorities. Non-root processes may 112set idle priority levels for the current process only. 113.Sh RETURN VALUE 114If 115.Nm rtprio 116execute a command, the exit value is that of the command executed. 117In all other cases, 118.Nm 119exits with 0 for success and 1 for all other errors. 120.Sh EXAMPLES 121.\LP 122 123To see which realtime priority the current process is at: 124.Bd -literal -offset indent -compact 125\fBrtprio\fP 126.Ed 127 128.\.LP 129To see which realtime priority of process \fI1423\fP: 130.Bd -literal -offset indent -compact 131\fBrtprio 1423\fP 132.Ed 133 134.\.LP 135To run \fIcron\fP at the lowest realtime priority: 136.Bd -literal -offset indent -compact 137\fBrtprio 31 cron\fP 138.Ed 139 140.\.LP 141To change the realtime priority of process \fI1423\fP to \fI16\fP: 142.Bd -literal -offset indent -compact 143\fBrtprio 16 -1423\fP 144.Ed 145 146.\.LP 147To run \fItcpdump\fP without realtime priority: 148.Bd -literal -offset indent -compact 149\fBrtprio -t tcpdump\fP 150.Ed 151 152.\.LP 153To change the realtime priority of process \fI1423\fP to RTP_PRIO_NORMAL 154(non-realtime/"normal" priority): 155.Bd -literal -offset indent -compact 156\fBrtprio -t -1423\fP 157.Ed 158 159.\.LP 160To make depend while not disturbing other machine usage: 161.Bd -literal -offset indent -compact 162\fBidprio 31 make depend\fP 163.Ed 164.Sh SEE ALSO 165.Xr rtprio 2 , 166.Xr nice 1 , 167.Xr ps 1 , 168.Xr nice 2 , 169.Xr renice 8 170.Sh HISTORY 171The 172.Nm rtprio 173utility appeared in 174FreeBSD 2.0, 175but is similar to the HP-UX version. 176.Sh CAVEATS 177You can lock yourself out of the system by placing a cpu-heavy 178process in a realtime priority. 179.Sh BUGS 180There is no way to set/view the realtime priority of process 0 181(swapper) (see ps(1)). 182 183There is in 184FreeBSD 185no way to ensure that a process page is present in memory therefore 186the process may be stopped for pagein. (See mprotect(2), madvise(2)). 187 188Under 189FreeBSD 190system calls are currently never preempted, therefore non-realtime 191processes can starve realtime procesess, or idletime processes can 192starve normal priority processes. 193 194Others ... 195.Sh AUTHOR 196Henrik Vestergaard Draboel - hvd@terry.ping.dk is the original author. This 197implementation in FreeBSD was substantially rewritten by David Greenman. 198