summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/Makefile2
-rw-r--r--usr.sbin/rtprio/Makefile7
-rw-r--r--usr.sbin/rtprio/rtprio.1165
-rw-r--r--usr.sbin/rtprio/rtprio.c141
4 files changed, 314 insertions, 1 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index 0588cf4..0a9704f 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -5,7 +5,7 @@
# XXX TEMP. BROKEN: iostat xntpd
SUBDIR= accton amd arp chown chroot cron dbsym dev_mkdb diskpart \
edquota inetd kbdcontrol kgmon kvm_mkdb lpr mtree portmap pstat \
- pwd_mkdb quotaon repquota routed rmt rwhod sendmail \
+ pwd_mkdb quotaon repquota routed rmt rtprio rwhod sendmail \
sliplogin sysctl syslogd tcpdump traceroute trpt vidcontrol \
vipw ypbind yppoll ypset
diff --git a/usr.sbin/rtprio/Makefile b/usr.sbin/rtprio/Makefile
new file mode 100644
index 0000000..2ca8da9
--- /dev/null
+++ b/usr.sbin/rtprio/Makefile
@@ -0,0 +1,7 @@
+# from: @(#)Makefile 5.5 (Berkeley) 5/11/90
+# $Id: Makefile,v 1.2 1993/11/23 00:02:21 jtc Exp $
+
+BINDIR=/usr/sbin
+PROG= rtprio
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/rtprio/rtprio.1 b/usr.sbin/rtprio/rtprio.1
new file mode 100644
index 0000000..0b0fa7e
--- /dev/null
+++ b/usr.sbin/rtprio/rtprio.1
@@ -0,0 +1,165 @@
+.\"
+.\" Copyright (c) 1994, Henrik Vestergaard Draboel
+.\" 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.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Henrik Vestergaard Draboel.
+.\" 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.
+.\"
+.\" $Id$
+.\"
+.Dd July 23, 1994
+.Dt RTPRIO 1
+.Os
+.Sh NAME
+.Nm rtprio
+.Nd execute, examine or modify a utilitys or process realtime scheduling priority
+.Sh SYNOPSIS
+
+.Nm rtprio
+.Nm rtprio
+.Ar pid
+.Nm rtprio
+.Ar priority
+.Ar command
+.Op args
+.Nm rtprio
+.Ar priority
+.Ar -pid
+.Nm rtprio
+.Ar -t
+.Ar command
+.Op args
+.Nm rtprio
+.Ar -t
+.Ar -pid
+.Sh DESCRIPTION
+.Nm Rtprio
+is used for controlling realtime process scheduling. A process with a
+realtime priority is not subject to priority degradation, and will only
+be preempted by another process of equal or higher realtime priority.
+
+.Nm Rtprio
+called without arguments, will return the realtime priority
+of the current process.
+
+If
+.Nm rtprio
+is called with 1 argument, it will return the realtime priority
+of the process with the specified
+.Ar pid .
+
+If
+.Ar priority
+is specified, the process or program is run at that realtime priority.
+If
+.Ar -t
+is specified, the process or program is run as a normal (non-realtime)
+process.
+
+If
+.Ar -pid
+is specified, the process with that pid will be modified, else
+if
+.Ar command
+is specified, that program is run with its arguments.
+
+.Ar Priority
+is an integer between 0 (RTPRIO_MIN) and 31 (RTPRIO_MAX). 0 is the
+highest priority
+
+.Ar Pid
+of 0 means "the current process".
+
+Only root is allowed to set realtime priorities.
+.Sh RETURN VALUE
+.Nm rtprio
+returns the (new) realtime priority of the process (see rtprio(2)), or
+-1 for all usage errors.
+.Sh EXAMPLES
+.\LP
+
+To see which realtime priority the current process is at:
+.Bd -literal -offset indent -compact
+\fBrtprio\fP
+.Ed
+
+.\.LP
+To see which realtime priority of process \fI1423\fP:
+.Bd -literal -offset indent -compact
+\fBrtprio 1423\fP
+.Ed
+
+.\.LP
+To run \fIcron\fP at the lowest realtime priority:
+.Bd -literal -offset indent -compact
+\fBrtprio 31 cron\fP
+.Ed
+
+.\.LP
+To change the realtime priority of process \fI1423\fP to \fI16\fP:
+.Bd -literal -offset indent -compact
+\fBrtprio 16 -1423\fP
+.Ed
+
+.\.LP
+To run \fItcpdump\fP without realtime priority:
+.Bd -literal -offset indent -compact
+\fBrtprio -t tcpdump\fP
+.Ed
+
+.\.LP
+To change the realtime priority of process \fI1423\fP to RTRIO_RTOFF
+(no realtime):
+.Bd -literal -offset indent -compact
+\fBrtprio -t -1423\fP
+.Ed
+.Sh DIAGNOSTICS
+The
+.Nm rtprio
+utility shall exit with value of the (new) realtime priority of the
+program.
+.Sh SEE ALSO
+.Xr rtprio 2 ,
+.Xr nice 1 ,
+.Xr ps 1 ,
+.Xr nice 2 ,
+.Xr renice 8
+.Sh HISTORY
+The
+.Nm rtprio
+utility appeared in
+FreeBSD 2.0,
+but is similar to the HP-UX version.
+.Sh BUGS
+You can lock you're self out of the system, be placing at cpu-heavy
+process in a realtime priority.
+
+There is no way to set/view the realtime priority of process 0
+(swapper) (see ps(1)).
+
+Others ...
+.Sh AUTHOR
+Henrik Vestergaard Draboel - hvd@terry.ping.dk
diff --git a/usr.sbin/rtprio/rtprio.c b/usr.sbin/rtprio/rtprio.c
new file mode 100644
index 0000000..cc66fd4
--- /dev/null
+++ b/usr.sbin/rtprio/rtprio.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 1994 The Regents of the University of California.
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ */
+
+/* Copyright (c) 1994 Henrik Vestergaard Drabøl (hvd@terry.pping.dk) */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+/*static char sccsid[] = "from: @(#)rtprio.c 5.4 (Berkeley) 6/1/90";*/
+static char rcsid[] = "$Id: rtprio.c,v 1.2 1993/11/23 00:02:23 jtc Exp $";
+#endif /* not lint */
+
+#include <sys/time.h>
+#include <stdio.h>
+#include <sys/rtprio.h>
+#include <locale.h>
+#include <errno.h>
+#include <err.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+
+static void usage();
+
+int
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ int nrtprio = RTPRIO_RTOFF;
+ int proc=0;
+
+ setlocale(LC_ALL, "");
+ errno = 0;
+
+ switch (argc) {
+ case 2:
+ proc = abs(atoi(argv[1]));
+ /* FALLTHROUGH */
+
+ case 1:
+ nrtprio = rtprio(proc,RTPRIO_NOCHG);
+ fprintf(stderr,"rtprio: %d %s\n",
+ nrtprio,
+ nrtprio==RTPRIO_RTOFF?"(RTOFF)":"");
+ exit(nrtprio);
+ /* NOTREACHED */
+
+ default: {
+ switch (argv[1][0]) {
+ case '-':
+ if (strcmp(argv[1],"-t")==0)
+ nrtprio = RTPRIO_RTOFF;
+ else
+ usage();
+ break;
+
+ case '0':case '1':case '2':case '3':case '4':
+ case '5':case '6':case '7':case '8':case '9':
+ nrtprio = atoi (argv[1]);
+
+ if (errno== ERANGE) usage();
+ break;
+
+ default:
+ usage();
+ break;
+ }
+ switch (argv[2][0]) {
+ case '-':
+ proc = -atoi(argv[2]);
+
+ break;
+ }
+
+ errno = 0;
+
+ nrtprio = rtprio(proc, nrtprio);
+
+ if (errno) {
+ err (1, "rtprio");
+ /* NOTREACHED */
+ }
+
+ if (proc == 0) {
+ execvp(argv[2], &argv[2]);
+ err ((errno == ENOENT) ? 127 : 126, "%s", argv[2]);}
+ /* NOTREACHED */
+ }
+ }
+return(nrtprio);
+}
+
+static void
+usage()
+{
+ (void)fprintf(stderr, "usage: rtprio\n");
+ (void)fprintf(stderr, "usage: rtprio [-] pid\n");
+ (void)fprintf(stderr, "usage: rtprio priority command [ args ] \n");
+ (void)fprintf(stderr, "usage: rtprio priority -pid \n");
+ (void)fprintf(stderr, "usage: rtprio -t command [ args ] \n");
+ (void)fprintf(stderr, "usage: rtprio -t -pid \n");
+
+ exit(-1);
+}
OpenPOWER on IntegriCloud