xref: /freebsd/usr.sbin/rtprio/rtprio.1 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
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.\"
31*a9545eedSFlorian Walpen.Dd December 8, 2021
3221e95dddSDavid Greenman.Dt RTPRIO 1
3321e95dddSDavid Greenman.Os
3421e95dddSDavid Greenman.Sh NAME
357216391eSDavid Greenman.Nm rtprio ,
367216391eSDavid Greenman.Nm idprio
37bf58fc26SJames Raynard.Nd execute, examine or modify a utility's or process's realtime
387216391eSDavid Greenmanor idletime scheduling priority
3921e95dddSDavid Greenman.Sh SYNOPSIS
407216391eSDavid Greenman.Nm [id|rt]prio
417216391eSDavid Greenman.Nm [id|rt]prio
42610a5778SRuslan Ermilov.Oo Fl Oc Ns Ar pid
437216391eSDavid Greenman.Nm [id|rt]prio
4421e95dddSDavid Greenman.Ar priority
4521e95dddSDavid Greenman.Ar command
4621e95dddSDavid Greenman.Op args
477216391eSDavid Greenman.Nm [id|rt]prio
4821e95dddSDavid Greenman.Ar priority
49610a5778SRuslan Ermilov.Fl Ar pid
507216391eSDavid Greenman.Nm [id|rt]prio
514f09442bSMike Pritchard.Fl t
5221e95dddSDavid Greenman.Ar command
5321e95dddSDavid Greenman.Op args
547216391eSDavid Greenman.Nm [id|rt]prio
554f09442bSMike Pritchard.Fl t
56610a5778SRuslan Ermilov.Fl Ar pid
5721e95dddSDavid Greenman.Sh DESCRIPTION
587f94b8deSPhilippe CharnierThe
597f94b8deSPhilippe Charnier.Nm
607f94b8deSPhilippe Charnierutility is used for controlling realtime process scheduling.
614f09442bSMike Pritchard.Pp
627f94b8deSPhilippe CharnierThe
637f94b8deSPhilippe Charnier.Nm idprio
647f94b8deSPhilippe Charnierutility is used for controlling idletime process scheduling, and can be called
657216391eSDavid Greenmanwith the same options as
66e97407b4SRuslan Ermilov.Nm .
674f09442bSMike Pritchard.Pp
687216391eSDavid GreenmanA process with a realtime priority is not subject to priority
697216391eSDavid Greenmandegradation, and will only be preempted by another process of equal or
707216391eSDavid Greenmanhigher realtime priority.
714f09442bSMike Pritchard.Pp
727216391eSDavid GreenmanA process with an idle priority will run only when no other
73bf58fc26SJames Raynardprocess is runnable and then only if its idle priority is equal or
747216391eSDavid Greenmangreater than all other runnable idle priority processes.
754f09442bSMike Pritchard.Pp
767f94b8deSPhilippe CharnierBoth
777f94b8deSPhilippe Charnier.Nm
787216391eSDavid Greenmanor
797f1550edSPhilippe Charnier.Nm idprio
807216391eSDavid Greenmanwhen called without arguments will return the realtime priority
8121e95dddSDavid Greenmanof the current process.
824f09442bSMike Pritchard.Pp
8321e95dddSDavid GreenmanIf
847f1550edSPhilippe Charnier.Nm
8521e95dddSDavid Greenmanis called with 1 argument, it will return the realtime priority
8621e95dddSDavid Greenmanof the process with the specified
8721e95dddSDavid Greenman.Ar pid .
884f09442bSMike Pritchard.Pp
8921e95dddSDavid GreenmanIf
9021e95dddSDavid Greenman.Ar priority
9121e95dddSDavid Greenmanis specified, the process or program is run at that realtime priority.
9221e95dddSDavid GreenmanIf
934f09442bSMike Pritchard.Fl t
9421e95dddSDavid Greenmanis specified, the process or program is run as a normal (non-realtime)
9521e95dddSDavid Greenmanprocess.
964f09442bSMike Pritchard.Pp
9721e95dddSDavid GreenmanIf
9821e95dddSDavid Greenman.Ar -pid
997f1550edSPhilippe Charnieris specified, the process with the process identifier
1007f1550edSPhilippe Charnier.Ar pid
1017f1550edSPhilippe Charnierwill be modified, else if
10221e95dddSDavid Greenman.Ar command
10321e95dddSDavid Greenmanis specified, that program is run with its arguments.
1044f09442bSMike Pritchard.Pp
10521e95dddSDavid Greenman.Ar Priority
10607bfccd7SRuslan Ermilovis an integer between 0 and RTP_PRIO_MAX (usually 31).
10707bfccd7SRuslan Ermilov0 is the
10821e95dddSDavid Greenmanhighest priority
1094f09442bSMike Pritchard.Pp
11021e95dddSDavid Greenman.Ar Pid
11121e95dddSDavid Greenmanof 0 means "the current process".
1124f09442bSMike Pritchard.Pp
113319e22e5SJordan K. HubbardOnly root is allowed to set realtime or idle priority for a process.
114bf2fa8d9SFlorian WalpenExceptional privileges can be granted through the
115bf2fa8d9SFlorian Walpen.Xr mac_priority 4
116*a9545eedSFlorian Walpenpolicy and the realtime and idletime user groups.
117*a9545eedSFlorian WalpenThe
1183afe9c0eSEitan Adler.Xr sysctl 8
1193afe9c0eSEitan Adlervariable
1203afe9c0eSEitan Adler.Va security.bsd.unprivileged_idprio
121*a9545eedSFlorian Walpenis deprecated.
122*a9545eedSFlorian WalpenIf set to non-zero, it lets any user modify the idle priority of processes
123*a9545eedSFlorian Walpenthey own.
124*a9545eedSFlorian Walpen.Pp
125*a9545eedSFlorian WalpenNote that idle priority increases the chance that a deadlock can occur
1263afe9c0eSEitan Adlerif a process locks a required resource and then does
1273afe9c0eSEitan Adlernot get to run.
128a866e170SRuslan Ermilov.Sh EXIT STATUS
1297216391eSDavid GreenmanIf
1307f1550edSPhilippe Charnier.Nm
1317216391eSDavid Greenmanexecute a command, the exit value is that of the command executed.
1327216391eSDavid GreenmanIn all other cases,
1337216391eSDavid Greenman.Nm
13497a729ffSPhilippe Charnierexits 0 on success, and 1 for all other errors.
13521e95dddSDavid Greenman.Sh EXAMPLES
13621e95dddSDavid GreenmanTo see which realtime priority the current process is at:
1376a5796e7SRuslan Ermilov.Dl rtprio
1384f09442bSMike Pritchard.Pp
1396a5796e7SRuslan ErmilovTo see which realtime priority of process 1423:
1406a5796e7SRuslan Ermilov.Dl "rtprio 1423"
1414f09442bSMike Pritchard.Pp
1424f09442bSMike PritchardTo run
1434f09442bSMike Pritchard.Xr cron 8
1444f09442bSMike Pritchardat the lowest realtime priority:
1456a5796e7SRuslan Ermilov.Dl "rtprio 31 cron"
1464f09442bSMike Pritchard.Pp
1476a5796e7SRuslan ErmilovTo change the realtime priority of process 1423 to 16:
1486a5796e7SRuslan Ermilov.Dl "rtprio 16 -1423"
1494f09442bSMike Pritchard.Pp
1504f09442bSMike PritchardTo run
151f437b38cSChris Costello.Xr tcpdump 1
1524f09442bSMike Pritchardwithout realtime priority:
1536a5796e7SRuslan Ermilov.Dl "rtprio -t tcpdump"
1544f09442bSMike Pritchard.Pp
1556a5796e7SRuslan ErmilovTo change the realtime priority of process 1423
1564f09442bSMike Pritchardto
1574f09442bSMike Pritchard.Dv RTP_PRIO_NORMAL
1587f1550edSPhilippe Charnier(non-realtime/normal priority):
1596a5796e7SRuslan Ermilov.Dl "rtprio -t -1423"
1604f09442bSMike Pritchard.Pp
1617216391eSDavid GreenmanTo make depend while not disturbing other machine usage:
1626a5796e7SRuslan Ermilov.Dl "idprio 31 make depend"
16321e95dddSDavid Greenman.Sh SEE ALSO
16421e95dddSDavid Greenman.Xr nice 1 ,
16521e95dddSDavid Greenman.Xr ps 1 ,
166bfd34a4aSWolfram Schneider.Xr rtprio 2 ,
16778b0b234SMike Pritchard.Xr setpriority 2 ,
16878b0b234SMike Pritchard.Xr nice 3 ,
169bf2fa8d9SFlorian Walpen.Xr mac_priority 4 ,
17021e95dddSDavid Greenman.Xr renice 8
17121e95dddSDavid Greenman.Sh HISTORY
17221e95dddSDavid GreenmanThe
1737f1550edSPhilippe Charnier.Nm
17421e95dddSDavid Greenmanutility appeared in
17585cf659aSMike Pritchard.Fx 2.0 ,
17621e95dddSDavid Greenmanbut is similar to the HP-UX version.
17759a3c79dSRuslan Ermilov.Sh AUTHORS
17859a3c79dSRuslan Ermilov.An -nosplit
17901c2b8acSBaptiste Daroussin.An Henrik Vestergaard Draboel Aq Mt hvd@terry.ping.dk
18059a3c79dSRuslan Ermilovis the original author.
18159a3c79dSRuslan ErmilovThis
18259a3c79dSRuslan Ermilovimplementation in
18359a3c79dSRuslan Ermilov.Fx
18459a3c79dSRuslan Ermilovwas substantially rewritten by
18559a3c79dSRuslan Ermilov.An David Greenman .
1860afc94c1SUlrich Spörlein.Sh CAVEATS
1870afc94c1SUlrich SpörleinYou can lock yourself out of the system by placing a cpu-heavy
1880afc94c1SUlrich Spörleinprocess in a realtime priority.
18921e95dddSDavid Greenman.Sh BUGS
19021e95dddSDavid GreenmanThere is no way to set/view the realtime priority of process 0
1914f09442bSMike Pritchard(swapper) (see
192c7535473SMike Pritchard.Xr ps 1 ) .
1934f09442bSMike Pritchard.Pp
1947216391eSDavid GreenmanThere is in
195b5c508fbSRuslan Ermilov.Fx
1967216391eSDavid Greenmanno way to ensure that a process page is present in memory therefore
1977f1550edSPhilippe Charnierthe process may be stopped for pagein (see
1984f09442bSMike Pritchard.Xr mprotect 2 ,
199c7535473SMike Pritchard.Xr madvise 2 ) .
2004f09442bSMike Pritchard.Pp
2017216391eSDavid GreenmanUnder
202b5c508fbSRuslan Ermilov.Fx
2037216391eSDavid Greenmansystem calls are currently never preempted, therefore non-realtime
2044a8d0283SMike Pritchardprocesses can starve realtime processes, or idletime processes can
2057216391eSDavid Greenmanstarve normal priority processes.
206