121e95dddSDavid Greenman.\" 221e95dddSDavid Greenman.\" Copyright (c) 1994, Henrik Vestergaard Draboel 321e95dddSDavid Greenman.\" All rights reserved. 421e95dddSDavid Greenman.\" 521e95dddSDavid Greenman.\" Redistribution and use in source and binary forms, with or without 621e95dddSDavid Greenman.\" modification, are permitted provided that the following conditions 721e95dddSDavid Greenman.\" are met: 821e95dddSDavid Greenman.\" 1. Redistributions of source code must retain the above copyright 921e95dddSDavid Greenman.\" notice, this list of conditions and the following disclaimer. 1021e95dddSDavid Greenman.\" 2. Redistributions in binary form must reproduce the above copyright 1121e95dddSDavid Greenman.\" notice, this list of conditions and the following disclaimer in the 1221e95dddSDavid Greenman.\" documentation and/or other materials provided with the distribution. 1321e95dddSDavid Greenman.\" 3. All advertising materials mentioning features or use of this software 1421e95dddSDavid Greenman.\" must display the following acknowledgement: 1521e95dddSDavid Greenman.\" This product includes software developed by Henrik Vestergaard Draboel. 1621e95dddSDavid Greenman.\" 4. The name of the author may not be used to endorse or promote products 1721e95dddSDavid Greenman.\" derived from this software without specific prior written permission. 1821e95dddSDavid Greenman.\" 1921e95dddSDavid Greenman.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2021e95dddSDavid Greenman.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2121e95dddSDavid Greenman.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2221e95dddSDavid Greenman.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2321e95dddSDavid Greenman.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2421e95dddSDavid Greenman.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2521e95dddSDavid Greenman.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2621e95dddSDavid Greenman.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2721e95dddSDavid Greenman.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2821e95dddSDavid Greenman.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2921e95dddSDavid Greenman.\" SUCH DAMAGE. 3021e95dddSDavid Greenman.\" 311130b656SJordan K. Hubbard.\" $FreeBSD$ 3221e95dddSDavid Greenman.\" 3321e95dddSDavid Greenman.Dd July 23, 1994 3421e95dddSDavid Greenman.Dt RTPRIO 1 3521e95dddSDavid Greenman.Os 3621e95dddSDavid Greenman.Sh NAME 377216391eSDavid Greenman.Nm rtprio , 387216391eSDavid Greenman.Nm idprio 397216391eSDavid Greenman.Nd execute, examine or modify a utilitys or process realtime 407216391eSDavid Greenmanor idletime scheduling priority 4121e95dddSDavid Greenman.Sh SYNOPSIS 4221e95dddSDavid Greenman 437216391eSDavid Greenman.Nm [id|rt]prio 447216391eSDavid Greenman.Nm [id|rt]prio 4521e95dddSDavid Greenman.Ar pid 467216391eSDavid Greenman.Nm [id|rt]prio 4721e95dddSDavid Greenman.Ar priority 4821e95dddSDavid Greenman.Ar command 4921e95dddSDavid Greenman.Op args 507216391eSDavid Greenman.Nm [id|rt]prio 5121e95dddSDavid Greenman.Ar priority 5221e95dddSDavid Greenman.Ar -pid 537216391eSDavid Greenman.Nm [id|rt]prio 5421e95dddSDavid Greenman.Ar -t 5521e95dddSDavid Greenman.Ar command 5621e95dddSDavid Greenman.Op args 577216391eSDavid Greenman.Nm [id|rt]prio 5821e95dddSDavid Greenman.Ar -t 5921e95dddSDavid Greenman.Ar -pid 6021e95dddSDavid Greenman.Sh DESCRIPTION 6121e95dddSDavid Greenman.Nm Rtprio 627216391eSDavid Greenmanis used for controlling realtime process scheduling. 637216391eSDavid Greenman 647216391eSDavid Greenman.Nm Idprio 657216391eSDavid Greenmanis used for controlling idletime process scheduling, and can be called 667216391eSDavid Greenmanwith the same options as 677216391eSDavid Greenman.Nm Rtprio . 687216391eSDavid Greenman 697216391eSDavid GreenmanA process with a realtime priority is not subject to priority 707216391eSDavid Greenmandegradation, and will only be preempted by another process of equal or 717216391eSDavid Greenmanhigher realtime priority. 727216391eSDavid Greenman 737216391eSDavid GreenmanA process with an idle priority will run only when no other 747216391eSDavid Greenmanprocess is runnable and then only if it's idle priority is equal or 757216391eSDavid Greenmangreater than all other runnable idle priority processes. 7621e95dddSDavid Greenman 7721e95dddSDavid Greenman.Nm Rtprio 787216391eSDavid Greenmanor 797216391eSDavid Greenman.Nm Idprio 807216391eSDavid Greenmanwhen called without arguments will return the realtime priority 8121e95dddSDavid Greenmanof the current process. 8221e95dddSDavid Greenman 8321e95dddSDavid GreenmanIf 8421e95dddSDavid Greenman.Nm rtprio 8521e95dddSDavid Greenmanis called with 1 argument, it will return the realtime priority 8621e95dddSDavid Greenmanof the process with the specified 8721e95dddSDavid Greenman.Ar pid . 8821e95dddSDavid Greenman 8921e95dddSDavid GreenmanIf 9021e95dddSDavid Greenman.Ar priority 9121e95dddSDavid Greenmanis specified, the process or program is run at that realtime priority. 9221e95dddSDavid GreenmanIf 9321e95dddSDavid Greenman.Ar -t 9421e95dddSDavid Greenmanis specified, the process or program is run as a normal (non-realtime) 9521e95dddSDavid Greenmanprocess. 9621e95dddSDavid Greenman 9721e95dddSDavid GreenmanIf 9821e95dddSDavid Greenman.Ar -pid 997216391eSDavid Greenmanis specified, the process with the process identifier "pid" will be 1007216391eSDavid Greenmanmodified, else if 10121e95dddSDavid Greenman.Ar command 10221e95dddSDavid Greenmanis specified, that program is run with its arguments. 10321e95dddSDavid Greenman 10421e95dddSDavid Greenman.Ar Priority 1057216391eSDavid Greenmanis an integer between 0 and RTP_PRIO_MAX (usually 31). 0 is the 10621e95dddSDavid Greenmanhighest priority 10721e95dddSDavid Greenman 10821e95dddSDavid Greenman.Ar Pid 10921e95dddSDavid Greenmanof 0 means "the current process". 11021e95dddSDavid Greenman 1117216391eSDavid GreenmanOnly root is allowed to set realtime priorities. Non-root processes may 1127216391eSDavid Greenmanset idle priority levels for the current process only. 11321e95dddSDavid Greenman.Sh RETURN VALUE 1147216391eSDavid GreenmanIf 11521e95dddSDavid Greenman.Nm rtprio 1167216391eSDavid Greenmanexecute a command, the exit value is that of the command executed. 1177216391eSDavid GreenmanIn all other cases, 1187216391eSDavid Greenman.Nm 1197216391eSDavid Greenmanexits with 0 for success and 1 for all other errors. 12021e95dddSDavid Greenman.Sh EXAMPLES 12121e95dddSDavid Greenman.\LP 12221e95dddSDavid Greenman 12321e95dddSDavid GreenmanTo see which realtime priority the current process is at: 12421e95dddSDavid Greenman.Bd -literal -offset indent -compact 12521e95dddSDavid Greenman\fBrtprio\fP 12621e95dddSDavid Greenman.Ed 12721e95dddSDavid Greenman 12821e95dddSDavid Greenman.\.LP 12921e95dddSDavid GreenmanTo see which realtime priority of process \fI1423\fP: 13021e95dddSDavid Greenman.Bd -literal -offset indent -compact 13121e95dddSDavid Greenman\fBrtprio 1423\fP 13221e95dddSDavid Greenman.Ed 13321e95dddSDavid Greenman 13421e95dddSDavid Greenman.\.LP 13521e95dddSDavid GreenmanTo run \fIcron\fP at the lowest realtime priority: 13621e95dddSDavid Greenman.Bd -literal -offset indent -compact 13721e95dddSDavid Greenman\fBrtprio 31 cron\fP 13821e95dddSDavid Greenman.Ed 13921e95dddSDavid Greenman 14021e95dddSDavid Greenman.\.LP 14121e95dddSDavid GreenmanTo change the realtime priority of process \fI1423\fP to \fI16\fP: 14221e95dddSDavid Greenman.Bd -literal -offset indent -compact 14321e95dddSDavid Greenman\fBrtprio 16 -1423\fP 14421e95dddSDavid Greenman.Ed 14521e95dddSDavid Greenman 14621e95dddSDavid Greenman.\.LP 14721e95dddSDavid GreenmanTo run \fItcpdump\fP without realtime priority: 14821e95dddSDavid Greenman.Bd -literal -offset indent -compact 14921e95dddSDavid Greenman\fBrtprio -t tcpdump\fP 15021e95dddSDavid Greenman.Ed 15121e95dddSDavid Greenman 15221e95dddSDavid Greenman.\.LP 1537216391eSDavid GreenmanTo change the realtime priority of process \fI1423\fP to RTP_PRIO_NORMAL 1547216391eSDavid Greenman(non-realtime/"normal" priority): 15521e95dddSDavid Greenman.Bd -literal -offset indent -compact 15621e95dddSDavid Greenman\fBrtprio -t -1423\fP 15721e95dddSDavid Greenman.Ed 1587216391eSDavid Greenman 1597216391eSDavid Greenman.\.LP 1607216391eSDavid GreenmanTo make depend while not disturbing other machine usage: 1617216391eSDavid Greenman.Bd -literal -offset indent -compact 1627216391eSDavid Greenman\fBidprio 31 make depend\fP 1637216391eSDavid Greenman.Ed 16421e95dddSDavid Greenman.Sh SEE ALSO 16521e95dddSDavid Greenman.Xr nice 1 , 16621e95dddSDavid Greenman.Xr ps 1 , 167bfd34a4aSWolfram Schneider.Xr rtprio 2 , 16878b0b234SMike Pritchard.Xr setpriority 2 , 16978b0b234SMike Pritchard.Xr nice 3 , 17021e95dddSDavid Greenman.Xr renice 8 17121e95dddSDavid Greenman.Sh HISTORY 17221e95dddSDavid GreenmanThe 17321e95dddSDavid Greenman.Nm rtprio 17421e95dddSDavid Greenmanutility appeared in 17585cf659aSMike Pritchard.Fx 2.0 , 17621e95dddSDavid Greenmanbut is similar to the HP-UX version. 1777216391eSDavid Greenman.Sh CAVEATS 1787216391eSDavid GreenmanYou can lock yourself out of the system by placing a cpu-heavy 1797216391eSDavid Greenmanprocess in a realtime priority. 18021e95dddSDavid Greenman.Sh BUGS 18121e95dddSDavid GreenmanThere is no way to set/view the realtime priority of process 0 18221e95dddSDavid Greenman(swapper) (see ps(1)). 18321e95dddSDavid Greenman 1847216391eSDavid GreenmanThere is in 18585cf659aSMike Pritchard.Tn FreeBSD 1867216391eSDavid Greenmanno way to ensure that a process page is present in memory therefore 1877216391eSDavid Greenmanthe process may be stopped for pagein. (See mprotect(2), madvise(2)). 1887216391eSDavid Greenman 1897216391eSDavid GreenmanUnder 19085cf659aSMike Pritchard.Tn FreeBSD 1917216391eSDavid Greenmansystem calls are currently never preempted, therefore non-realtime 1924a8d0283SMike Pritchardprocesses can starve realtime processes, or idletime processes can 1937216391eSDavid Greenmanstarve normal priority processes. 1947216391eSDavid Greenman 19521e95dddSDavid GreenmanOthers ... 19621e95dddSDavid Greenman.Sh AUTHOR 1977216391eSDavid GreenmanHenrik Vestergaard Draboel - hvd@terry.ping.dk is the original author. This 19885cf659aSMike Pritchardimplementation in 19985cf659aSMike Pritchard.Tn FreeBSD 20085cf659aSMike Pritchardwas substantially rewritten by David Greenman. 201