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.\" $FreeBSD: src/usr.sbin/rtprio/rtprio.1,v 1.19.2.4 2002/06/21 16:42:31 charnier Exp $ 32.\" $DragonFly: src/usr.sbin/rtprio/rtprio.1,v 1.2 2003/06/17 04:30:03 dillon Exp $ 33.\" 34.Dd July 23, 1994 35.Dt RTPRIO 1 36.Os 37.Sh NAME 38.Nm rtprio , 39.Nm idprio 40.Nd execute, examine or modify a utility's or process's realtime 41or idletime scheduling priority 42.Sh SYNOPSIS 43.Nm [id|rt]prio 44.Nm [id|rt]prio 45.Oo Fl Oc Ns 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.Fl Ar pid 53.Nm [id|rt]prio 54.Fl t 55.Ar command 56.Op args 57.Nm [id|rt]prio 58.Fl t 59.Fl Ar pid 60.Sh DESCRIPTION 61The 62.Nm 63utility is used for controlling realtime process scheduling. 64.Pp 65The 66.Nm idprio 67utility is used for controlling idletime process scheduling, and can be called 68with the same options as 69.Nm . 70.Pp 71A process with a realtime priority is not subject to priority 72degradation, and will only be preempted by another process of equal or 73higher realtime priority. 74.Pp 75A process with an idle priority will run only when no other 76process is runnable and then only if its idle priority is equal or 77greater than all other runnable idle priority processes. 78.Pp 79Both 80.Nm 81or 82.Nm idprio 83when called without arguments will return the realtime priority 84of the current process. 85.Pp 86If 87.Nm 88is called with 1 argument, it will return the realtime priority 89of the process with the specified 90.Ar pid . 91.Pp 92If 93.Ar priority 94is specified, the process or program is run at that realtime priority. 95If 96.Fl t 97is specified, the process or program is run as a normal (non-realtime) 98process. 99.Pp 100If 101.Ar -pid 102is specified, the process with the process identifier 103.Ar pid 104will be modified, else if 105.Ar command 106is specified, that program is run with its arguments. 107.Pp 108.Ar Priority 109is an integer between 0 and RTP_PRIO_MAX (usually 31). 0 is the 110highest priority 111.Pp 112.Ar Pid 113of 0 means "the current process". 114.Pp 115Only root is allowed to set realtime or idle priority for a process. 116.Sh DIAGNOSTICS 117If 118.Nm 119execute a command, the exit value is that of the command executed. 120In all other cases, 121.Nm 122exits 0 on success, and 1 for all other errors. 123.Sh EXAMPLES 124To see which realtime priority the current process is at: 125.Bd -literal -offset indent -compact 126.Sy "rtprio" 127.Ed 128.Pp 129To see which realtime priority of process 130.Em 1423 : 131.Bd -literal -offset indent -compact 132.Sy "rtprio 1423" 133.Ed 134.Pp 135To run 136.Xr cron 8 137at the lowest realtime priority: 138.Bd -literal -offset indent -compact 139.Sy "rtprio 31 cron" 140.Ed 141.Pp 142To change the realtime priority of process 143.Em 1423 144to 145.Em 16 : 146.Bd -literal -offset indent -compact 147.Sy "rtprio 16 -1423" 148.Ed 149.Pp 150To run 151.Xr tcpdump 1 152without realtime priority: 153.Bd -literal -offset indent -compact 154.Sy "rtprio -t tcpdump" 155.Ed 156.Pp 157To change the realtime priority of process 158.Em 1423 159to 160.Dv RTP_PRIO_NORMAL 161(non-realtime/normal priority): 162.Bd -literal -offset indent -compact 163.Sy "rtprio -t -1423" 164.Ed 165.Pp 166To make depend while not disturbing other machine usage: 167.Bd -literal -offset indent -compact 168.Sy "idprio 31 make depend" 169.Ed 170.Sh SEE ALSO 171.Xr nice 1 , 172.Xr ps 1 , 173.Xr rtprio 2 , 174.Xr setpriority 2 , 175.Xr nice 3 , 176.Xr renice 8 177.Sh HISTORY 178The 179.Nm 180utility appeared in 181.Fx 2.0 , 182but is similar to the HP-UX version. 183.Sh CAVEATS 184You can lock yourself out of the system by placing a cpu-heavy 185process in a realtime priority. 186.Sh BUGS 187There is no way to set/view the realtime priority of process 0 188(swapper) (see 189.Xr ps 1 ) . 190.Pp 191There is in 192.Fx 193no way to ensure that a process page is present in memory therefore 194the process may be stopped for pagein (see 195.Xr mprotect 2 , 196.Xr madvise 2 ) . 197.Pp 198Under 199.Fx 200system calls are currently never preempted, therefore non-realtime 201processes can starve realtime processes, or idletime processes can 202starve normal priority processes. 203.Sh AUTHORS 204.An -nosplit 205.An Henrik Vestergaard Draboel Aq hvd@terry.ping.dk 206is the original author. 207This 208implementation in 209.Fx 210was substantially rewritten by 211.An David Greenman . 212