1.\" Copyright (c) 1994, Henrik Vestergaard Draboel 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by Henrik Vestergaard Draboel. 15.\" 4. The name of the author may not be used to endorse or promote products 16.\" derived from this software without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" $FreeBSD: src/lib/libc/sys/rtprio.2,v 1.13.2.9 2001/12/14 18:34:01 ru Exp $ 31.\" 32.Dd December 14, 2007 33.Dt RTPRIO 2 34.Os 35.Sh NAME 36.Nm rtprio , 37.Nm lwp_rtprio 38.Nd examine or modify a process/lwp realtime or idle priority 39.Sh LIBRARY 40.Lb libc 41.Sh SYNOPSIS 42.In sys/types.h 43.In sys/rtprio.h 44.Ft int 45.Fn rtprio "int function" "pid_t pid" "struct rtprio *rtp" 46.In sys/lwp.h 47.Ft int 48.Fn lwp_rtprio "int function" "pid_t pid" "lwpid_t tid" "struct rtprio *rtp" 49.Sh DESCRIPTION 50.Fn rtprio 51is used to lookup or change the realtime or idle priority of a process. 52.Pp 53.Fa function 54specifies the operation to be performed. 55.Dv RTP_LOOKUP 56to lookup the current priority, and 57.Dv RTP_SET 58to set the priority. 59.Fa pid 60specifies the process to be used, 0 for the current process. 61.Pp 62.Fa *rtp 63is a pointer to a 64.Vt struct rtprio 65which is used to specify the priority and priority type. 66This structure has the following form: 67.Bd -literal 68struct rtprio { 69 u_short type; 70 u_short prio; 71}; 72.Ed 73.Pp 74The value of the 75.Nm type 76field may be 77.Dv RTP_PRIO_REALTIME 78for realtime priorities, 79.Dv RTP_PRIO_NORMAL 80for normal priorities, and 81.Dv RTP_PRIO_IDLE 82for idle priorities. 83The priority specified by the 84.Nm prio 85field ranges between 0 and 86.Dv RTP_PRIO_MAX 87(usually 31). 880 is the highest possible priority. 89.Pp 90Realtime and idle priority is inherited through 91.Fn fork 92and 93.Fn exec . 94.Pp 95A realtime process can only be preempted by a process of equal or 96higher priority, or by an interrupt; idle priority processes will run only 97when no other real/normal priority process is runnable. 98Higher real/idle priority processes 99preempt lower real/idle priority processes. 100Processes of equal real/idle priority are run round-robin. 101.Pp 102The 103.Fn lwp_rtprio 104function is the lwp counterpart of 105.Fn rtprio . 106It takes one additional argument, 107.Fa tid , 108specifying the lwp to be used, -1 for the current lwp. 109.Sh RETURN VALUES 110.Rv -std rtprio lwp_rtprio 111.Sh ERRORS 112.Fn rtprio 113and 114.Fn lwp_rtprio 115will fail if 116.Bl -tag -width Er 117.It Bq Er EINVAL 118The specified 119.Fa prio 120was out of range. 121.It Bq Er EPERM 122The calling process is not allowed to set the realtime priority. 123Only 124root is allowed to change the realtime priority of any process, and non-root 125may only change the idle priority of the current process. 126.It Bq Er ESRCH 127The specified process was not found. 128.El 129.Sh SEE ALSO 130.Xr nice 1 , 131.Xr ps 1 , 132.Xr rtprio 1 , 133.Xr setpriority 2 , 134.Xr nice 3 , 135.Xr renice 8 136.Sh AUTHORS 137.An -nosplit 138The original author was 139.An Henrik Vestergaard Draboel Aq Mt hvd@terry.ping.dk . 140This implementation was substantially rewritten by 141.An David Greenman . 142