xref: /freebsd/usr.sbin/rtprio/rtprio.1 (revision a9545eede43b8fac889f3ec3180f5917f0d0b0ea)
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.\"
3197d92980SPeter Wemm.\" $FreeBSD$
3221e95dddSDavid Greenman.\"
33*a9545eedSFlorian Walpen.Dd December 8, 2021
3421e95dddSDavid Greenman.Dt RTPRIO 1
3521e95dddSDavid Greenman.Os
3621e95dddSDavid Greenman.Sh NAME
377216391eSDavid Greenman.Nm rtprio ,
387216391eSDavid Greenman.Nm idprio
39bf58fc26SJames Raynard.Nd execute, examine or modify a utility's or process's realtime
407216391eSDavid Greenmanor idletime scheduling priority
4121e95dddSDavid Greenman.Sh SYNOPSIS
427216391eSDavid Greenman.Nm [id|rt]prio
437216391eSDavid Greenman.Nm [id|rt]prio
44610a5778SRuslan Ermilov.Oo Fl Oc Ns Ar pid
457216391eSDavid Greenman.Nm [id|rt]prio
4621e95dddSDavid Greenman.Ar priority
4721e95dddSDavid Greenman.Ar command
4821e95dddSDavid Greenman.Op args
497216391eSDavid Greenman.Nm [id|rt]prio
5021e95dddSDavid Greenman.Ar priority
51610a5778SRuslan Ermilov.Fl Ar pid
527216391eSDavid Greenman.Nm [id|rt]prio
534f09442bSMike Pritchard.Fl t
5421e95dddSDavid Greenman.Ar command
5521e95dddSDavid Greenman.Op args
567216391eSDavid Greenman.Nm [id|rt]prio
574f09442bSMike Pritchard.Fl t
58610a5778SRuslan Ermilov.Fl Ar pid
5921e95dddSDavid Greenman.Sh DESCRIPTION
607f94b8deSPhilippe CharnierThe
617f94b8deSPhilippe Charnier.Nm
627f94b8deSPhilippe Charnierutility is used for controlling realtime process scheduling.
634f09442bSMike Pritchard.Pp
647f94b8deSPhilippe CharnierThe
657f94b8deSPhilippe Charnier.Nm idprio
667f94b8deSPhilippe Charnierutility is used for controlling idletime process scheduling, and can be called
677216391eSDavid Greenmanwith the same options as
68e97407b4SRuslan Ermilov.Nm .
694f09442bSMike Pritchard.Pp
707216391eSDavid GreenmanA process with a realtime priority is not subject to priority
717216391eSDavid Greenmandegradation, and will only be preempted by another process of equal or
727216391eSDavid Greenmanhigher realtime priority.
734f09442bSMike Pritchard.Pp
747216391eSDavid GreenmanA process with an idle priority will run only when no other
75bf58fc26SJames Raynardprocess is runnable and then only if its idle priority is equal or
767216391eSDavid Greenmangreater than all other runnable idle priority processes.
774f09442bSMike Pritchard.Pp
787f94b8deSPhilippe CharnierBoth
797f94b8deSPhilippe Charnier.Nm
807216391eSDavid Greenmanor
817f1550edSPhilippe Charnier.Nm idprio
827216391eSDavid Greenmanwhen called without arguments will return the realtime priority
8321e95dddSDavid Greenmanof the current process.
844f09442bSMike Pritchard.Pp
8521e95dddSDavid GreenmanIf
867f1550edSPhilippe Charnier.Nm
8721e95dddSDavid Greenmanis called with 1 argument, it will return the realtime priority
8821e95dddSDavid Greenmanof the process with the specified
8921e95dddSDavid Greenman.Ar pid .
904f09442bSMike Pritchard.Pp
9121e95dddSDavid GreenmanIf
9221e95dddSDavid Greenman.Ar priority
9321e95dddSDavid Greenmanis specified, the process or program is run at that realtime priority.
9421e95dddSDavid GreenmanIf
954f09442bSMike Pritchard.Fl t
9621e95dddSDavid Greenmanis specified, the process or program is run as a normal (non-realtime)
9721e95dddSDavid Greenmanprocess.
984f09442bSMike Pritchard.Pp
9921e95dddSDavid GreenmanIf
10021e95dddSDavid Greenman.Ar -pid
1017f1550edSPhilippe Charnieris specified, the process with the process identifier
1027f1550edSPhilippe Charnier.Ar pid
1037f1550edSPhilippe Charnierwill be modified, else if
10421e95dddSDavid Greenman.Ar command
10521e95dddSDavid Greenmanis specified, that program is run with its arguments.
1064f09442bSMike Pritchard.Pp
10721e95dddSDavid Greenman.Ar Priority
10807bfccd7SRuslan Ermilovis an integer between 0 and RTP_PRIO_MAX (usually 31).
10907bfccd7SRuslan Ermilov0 is the
11021e95dddSDavid Greenmanhighest priority
1114f09442bSMike Pritchard.Pp
11221e95dddSDavid Greenman.Ar Pid
11321e95dddSDavid Greenmanof 0 means "the current process".
1144f09442bSMike Pritchard.Pp
115319e22e5SJordan K. HubbardOnly root is allowed to set realtime or idle priority for a process.
116bf2fa8d9SFlorian WalpenExceptional privileges can be granted through the
117bf2fa8d9SFlorian Walpen.Xr mac_priority 4
118*a9545eedSFlorian Walpenpolicy and the realtime and idletime user groups.
119*a9545eedSFlorian WalpenThe
1203afe9c0eSEitan Adler.Xr sysctl 8
1213afe9c0eSEitan Adlervariable
1223afe9c0eSEitan Adler.Va security.bsd.unprivileged_idprio
123*a9545eedSFlorian Walpenis deprecated.
124*a9545eedSFlorian WalpenIf set to non-zero, it lets any user modify the idle priority of processes
125*a9545eedSFlorian Walpenthey own.
126*a9545eedSFlorian Walpen.Pp
127*a9545eedSFlorian WalpenNote that idle priority increases the chance that a deadlock can occur
1283afe9c0eSEitan Adlerif a process locks a required resource and then does
1293afe9c0eSEitan Adlernot get to run.
130a866e170SRuslan Ermilov.Sh EXIT STATUS
1317216391eSDavid GreenmanIf
1327f1550edSPhilippe Charnier.Nm
1337216391eSDavid Greenmanexecute a command, the exit value is that of the command executed.
1347216391eSDavid GreenmanIn all other cases,
1357216391eSDavid Greenman.Nm
13697a729ffSPhilippe Charnierexits 0 on success, and 1 for all other errors.
13721e95dddSDavid Greenman.Sh EXAMPLES
13821e95dddSDavid GreenmanTo see which realtime priority the current process is at:
1396a5796e7SRuslan Ermilov.Dl rtprio
1404f09442bSMike Pritchard.Pp
1416a5796e7SRuslan ErmilovTo see which realtime priority of process 1423:
1426a5796e7SRuslan Ermilov.Dl "rtprio 1423"
1434f09442bSMike Pritchard.Pp
1444f09442bSMike PritchardTo run
1454f09442bSMike Pritchard.Xr cron 8
1464f09442bSMike Pritchardat the lowest realtime priority:
1476a5796e7SRuslan Ermilov.Dl "rtprio 31 cron"
1484f09442bSMike Pritchard.Pp
1496a5796e7SRuslan ErmilovTo change the realtime priority of process 1423 to 16:
1506a5796e7SRuslan Ermilov.Dl "rtprio 16 -1423"
1514f09442bSMike Pritchard.Pp
1524f09442bSMike PritchardTo run
153f437b38cSChris Costello.Xr tcpdump 1
1544f09442bSMike Pritchardwithout realtime priority:
1556a5796e7SRuslan Ermilov.Dl "rtprio -t tcpdump"
1564f09442bSMike Pritchard.Pp
1576a5796e7SRuslan ErmilovTo change the realtime priority of process 1423
1584f09442bSMike Pritchardto
1594f09442bSMike Pritchard.Dv RTP_PRIO_NORMAL
1607f1550edSPhilippe Charnier(non-realtime/normal priority):
1616a5796e7SRuslan Ermilov.Dl "rtprio -t -1423"
1624f09442bSMike Pritchard.Pp
1637216391eSDavid GreenmanTo make depend while not disturbing other machine usage:
1646a5796e7SRuslan Ermilov.Dl "idprio 31 make depend"
16521e95dddSDavid Greenman.Sh SEE ALSO
16621e95dddSDavid Greenman.Xr nice 1 ,
16721e95dddSDavid Greenman.Xr ps 1 ,
168bfd34a4aSWolfram Schneider.Xr rtprio 2 ,
16978b0b234SMike Pritchard.Xr setpriority 2 ,
17078b0b234SMike Pritchard.Xr nice 3 ,
171bf2fa8d9SFlorian Walpen.Xr mac_priority 4 ,
17221e95dddSDavid Greenman.Xr renice 8
17321e95dddSDavid Greenman.Sh HISTORY
17421e95dddSDavid GreenmanThe
1757f1550edSPhilippe Charnier.Nm
17621e95dddSDavid Greenmanutility appeared in
17785cf659aSMike Pritchard.Fx 2.0 ,
17821e95dddSDavid Greenmanbut is similar to the HP-UX version.
17959a3c79dSRuslan Ermilov.Sh AUTHORS
18059a3c79dSRuslan Ermilov.An -nosplit
18101c2b8acSBaptiste Daroussin.An Henrik Vestergaard Draboel Aq Mt hvd@terry.ping.dk
18259a3c79dSRuslan Ermilovis the original author.
18359a3c79dSRuslan ErmilovThis
18459a3c79dSRuslan Ermilovimplementation in
18559a3c79dSRuslan Ermilov.Fx
18659a3c79dSRuslan Ermilovwas substantially rewritten by
18759a3c79dSRuslan Ermilov.An David Greenman .
1880afc94c1SUlrich Spörlein.Sh CAVEATS
1890afc94c1SUlrich SpörleinYou can lock yourself out of the system by placing a cpu-heavy
1900afc94c1SUlrich Spörleinprocess in a realtime priority.
19121e95dddSDavid Greenman.Sh BUGS
19221e95dddSDavid GreenmanThere is no way to set/view the realtime priority of process 0
1934f09442bSMike Pritchard(swapper) (see
194c7535473SMike Pritchard.Xr ps 1 ) .
1954f09442bSMike Pritchard.Pp
1967216391eSDavid GreenmanThere is in
197b5c508fbSRuslan Ermilov.Fx
1987216391eSDavid Greenmanno way to ensure that a process page is present in memory therefore
1997f1550edSPhilippe Charnierthe process may be stopped for pagein (see
2004f09442bSMike Pritchard.Xr mprotect 2 ,
201c7535473SMike Pritchard.Xr madvise 2 ) .
2024f09442bSMike Pritchard.Pp
2037216391eSDavid GreenmanUnder
204b5c508fbSRuslan Ermilov.Fx
2057216391eSDavid Greenmansystem calls are currently never preempted, therefore non-realtime
2064a8d0283SMike Pritchardprocesses can starve realtime processes, or idletime processes can
2077216391eSDavid Greenmanstarve normal priority processes.
208