2011-12-27 10:34:00 +00:00
|
|
|
.\"-
|
1994-09-01 09:52:37 +00:00
|
|
|
.\" Copyright (c) 1994, Henrik Vestergaard Draboel
|
|
|
|
.\" All rights reserved.
|
2001-07-15 07:53:42 +00:00
|
|
|
.\"
|
1994-09-01 09:52:37 +00:00
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
1995-08-05 07:31:19 +00:00
|
|
|
.\" This product includes software developed by Henrik Vestergaard Draboel.
|
1994-09-01 09:52:37 +00:00
|
|
|
.\" 4. The name of the author may not be used to endorse or promote products
|
|
|
|
.\" derived from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
2011-12-27 10:34:00 +00:00
|
|
|
.\"-
|
|
|
|
.\" Copyright (c) 2011 Xin LI <delphij@FreeBSD.org>
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
2001-07-15 07:53:42 +00:00
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1994-09-01 09:52:37 +00:00
|
|
|
.\"
|
2011-12-27 10:34:00 +00:00
|
|
|
.Dd December 27, 2011
|
1994-09-01 09:52:37 +00:00
|
|
|
.Dt RTPRIO 2
|
2001-07-10 13:41:46 +00:00
|
|
|
.Os
|
1994-09-01 09:52:37 +00:00
|
|
|
.Sh NAME
|
2011-12-27 10:34:00 +00:00
|
|
|
.Nm rtprio ,
|
|
|
|
.Nm rtprio_thread
|
|
|
|
.Nd examine or modify realtime or idle priority
|
2000-04-21 09:42:15 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
1994-09-01 09:52:37 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/types.h
|
|
|
|
.In sys/rtprio.h
|
2001-07-15 07:53:42 +00:00
|
|
|
.Ft int
|
1996-05-01 01:18:43 +00:00
|
|
|
.Fn rtprio "int function" "pid_t pid" "struct rtprio *rtp"
|
2011-12-27 10:34:00 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn rtprio_thread "int function" "lwpid_t lwpid" "struct rtprio *rtp"
|
1994-09-01 09:52:37 +00:00
|
|
|
.Sh DESCRIPTION
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
1995-08-05 07:31:19 +00:00
|
|
|
.Fn rtprio
|
2002-12-18 09:22:32 +00:00
|
|
|
system call
|
2011-12-27 10:34:00 +00:00
|
|
|
is used to lookup or change the realtime or idle priority of a process,
|
|
|
|
or the calling thread.
|
|
|
|
The
|
|
|
|
.Fn rtprio_thread
|
|
|
|
system call
|
|
|
|
is used to lookup or change the realtime or idle priority of a thread.
|
2000-06-23 20:35:45 +00:00
|
|
|
.Pp
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
1995-08-05 07:31:19 +00:00
|
|
|
.Fa function
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
2000-03-02 09:14:21 +00:00
|
|
|
specifies the operation to be performed.
|
2001-07-15 07:53:42 +00:00
|
|
|
RTP_LOOKUP to lookup the current priority,
|
1995-08-05 07:31:19 +00:00
|
|
|
and RTP_SET to set the priority.
|
2011-12-27 10:34:00 +00:00
|
|
|
.Pp
|
|
|
|
For the
|
|
|
|
.Fn rtprio
|
|
|
|
system call,
|
|
|
|
the
|
1994-09-01 09:52:37 +00:00
|
|
|
.Fa pid
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
2011-12-27 10:34:00 +00:00
|
|
|
specifies the process to operate on,
|
|
|
|
0 for the calling thread.
|
|
|
|
When
|
|
|
|
.Fa pid
|
|
|
|
is non-zero,
|
|
|
|
the system call reports the highest priority in the process,
|
|
|
|
or sets all threads' priority in the process,
|
|
|
|
depending on value of the
|
|
|
|
.Fa function
|
|
|
|
argument.
|
|
|
|
.Pp
|
|
|
|
For the
|
|
|
|
.Fn rtprio_thread
|
|
|
|
system call,
|
|
|
|
the
|
|
|
|
.Fa lwpid
|
|
|
|
specifies the thread to operate on,
|
|
|
|
0 for the calling thread.
|
2000-06-23 20:35:45 +00:00
|
|
|
.Pp
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
1995-08-05 07:31:19 +00:00
|
|
|
.Fa *rtp
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
2001-07-15 07:53:42 +00:00
|
|
|
is a pointer to a struct rtprio which is used to specify the priority and priority type.
|
1995-08-05 07:31:19 +00:00
|
|
|
This structure has the following form:
|
|
|
|
.Bd -literal
|
|
|
|
struct rtprio {
|
|
|
|
u_short type;
|
|
|
|
u_short prio;
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The value of the
|
2002-12-18 09:22:32 +00:00
|
|
|
.Va type
|
1995-08-05 07:31:19 +00:00
|
|
|
field may be RTP_PRIO_REALTIME for realtime priorities,
|
|
|
|
RTP_PRIO_NORMAL for normal priorities, and RTP_PRIO_IDLE for idle priorities.
|
|
|
|
The priority specified by the
|
2002-12-18 09:22:32 +00:00
|
|
|
.Va prio
|
2001-07-15 07:53:42 +00:00
|
|
|
field ranges between 0 and
|
2012-05-08 18:56:21 +00:00
|
|
|
.Dv RTP_PRIO_MAX
|
|
|
|
.Pq usually 31 .
|
1994-09-01 09:52:37 +00:00
|
|
|
0 is the highest possible priority.
|
2000-06-23 20:35:45 +00:00
|
|
|
.Pp
|
1995-08-05 07:31:19 +00:00
|
|
|
Realtime and idle priority is inherited through fork() and exec().
|
2000-06-23 20:35:45 +00:00
|
|
|
.Pp
|
2011-12-27 10:34:00 +00:00
|
|
|
A realtime thread can only be preempted by a thread of equal or
|
|
|
|
higher priority, or by an interrupt; idle priority threads will run only
|
|
|
|
when no other real/normal priority thread is runnable.
|
|
|
|
Higher real/idle priority threads
|
|
|
|
preempt lower real/idle priority threads.
|
|
|
|
Threads of equal real/idle priority are run round-robin.
|
1994-09-01 09:52:37 +00:00
|
|
|
.Sh RETURN VALUES
|
2012-11-16 09:56:25 +00:00
|
|
|
.Rv -std rtprio rtprio_thread
|
1994-09-01 09:52:37 +00:00
|
|
|
.Sh ERRORS
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
1995-08-05 07:31:19 +00:00
|
|
|
.Fn rtprio
|
2012-11-16 09:56:25 +00:00
|
|
|
and
|
|
|
|
.Fn rtprio_thread
|
|
|
|
system calls
|
2012-05-08 18:56:21 +00:00
|
|
|
will fail if:
|
1994-09-01 09:52:37 +00:00
|
|
|
.Bl -tag -width Er
|
2012-11-16 09:56:25 +00:00
|
|
|
.It Bq Er EFAULT
|
|
|
|
The rtp pointer passed to
|
|
|
|
.Fn rtprio
|
|
|
|
or
|
|
|
|
.Fn rtprio_thread
|
|
|
|
was invalid.
|
1994-09-01 09:52:37 +00:00
|
|
|
.It Bq Er EINVAL
|
|
|
|
The specified
|
|
|
|
.Fa prio
|
|
|
|
was out of range.
|
|
|
|
.It Bq Er EPERM
|
2011-12-27 10:34:00 +00:00
|
|
|
The calling thread is not allowed to set the realtime priority.
|
2000-03-02 09:14:21 +00:00
|
|
|
Only
|
2011-12-27 10:34:00 +00:00
|
|
|
root is allowed to change the realtime priority of any thread, and non-root
|
|
|
|
may only change the idle priority of threads the user owns,
|
|
|
|
when the
|
|
|
|
.Xr sysctl 8
|
|
|
|
variable
|
|
|
|
.Va security.bsd.unprivileged_idprio
|
|
|
|
is set to non-zero.
|
1994-09-01 09:52:37 +00:00
|
|
|
.It Bq Er ESRCH
|
2011-12-27 10:34:00 +00:00
|
|
|
The specified process or thread was not found or visible.
|
2000-12-29 14:08:20 +00:00
|
|
|
.El
|
2005-01-20 09:17:07 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr nice 1 ,
|
|
|
|
.Xr ps 1 ,
|
|
|
|
.Xr rtprio 1 ,
|
|
|
|
.Xr setpriority 2 ,
|
|
|
|
.Xr nice 3 ,
|
2011-12-27 10:34:00 +00:00
|
|
|
.Xr renice 8 ,
|
2012-05-08 18:56:21 +00:00
|
|
|
.Xr p_cansee 9
|
1998-03-19 07:34:22 +00:00
|
|
|
.Sh AUTHORS
|
2000-11-22 09:23:54 +00:00
|
|
|
.An -nosplit
|
1998-03-19 07:34:22 +00:00
|
|
|
The original author was
|
2014-06-23 08:25:03 +00:00
|
|
|
.An Henrik Vestergaard Draboel Aq Mt hvd@terry.ping.dk .
|
1998-03-19 07:34:22 +00:00
|
|
|
This implementation in
|
1999-09-05 07:02:22 +00:00
|
|
|
.Fx
|
1998-03-19 07:34:22 +00:00
|
|
|
was substantially rewritten by
|
|
|
|
.An David Greenman .
|
2011-12-27 10:34:00 +00:00
|
|
|
The
|
|
|
|
.Fn rtprio_thread
|
|
|
|
system call was implemented by
|
|
|
|
.An David Xu .
|