Allow starting a new process with the specified parameters. For example:
# schedctl -C SCHED_FIFO top
This commit is contained in:
parent
9d0947ae6e
commit
e25a4f7edc
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: schedctl.8,v 1.5 2008/04/30 13:11:02 martin Exp $
|
||||
.\" $NetBSD: schedctl.8,v 1.6 2008/05/25 23:22:16 ad Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
|
@ -27,7 +27,7 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd April 28, 2008
|
||||
.Dd May 26, 2008
|
||||
.Dt SCHEDCTL 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -35,29 +35,31 @@
|
|||
.Nd control scheduling of processes and threads
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Fl p Ar pid
|
||||
.Op Fl A Ar processors
|
||||
.Op Fl A Ar cpus
|
||||
.Op Fl C Ar class
|
||||
.Op Fl P Ar priority
|
||||
.Op Fl P Ar pri
|
||||
.Op Fl t Ar lid
|
||||
.Fl p Ar pid | Ar command
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
command can be used to control the scheduling of processes and threads.
|
||||
It also returns information about current scheduling parameters
|
||||
It also returns information about the current scheduling parameters
|
||||
of the process or thread.
|
||||
Only the super-user may change the scheduling parameters.
|
||||
.Nm
|
||||
can also be used to start a new command using the specified parameters.
|
||||
.Pp
|
||||
Available options:
|
||||
.Bl -tag -width indent
|
||||
.It Fl A Ar processors
|
||||
.It Fl A Ar cpus
|
||||
Set of the processors on which process or thread should run, that
|
||||
is, affinity.
|
||||
Processors are defined as numbers (starting from zero) and separated
|
||||
by commas.
|
||||
A value of \-1 is used to unset the affinity.
|
||||
.It Fl C Ar class
|
||||
Scheduling class (policy) might be:
|
||||
Scheduling class (policy), one of:
|
||||
.Bl -tag -width SCHEDOTHERXX
|
||||
.It Dv SCHED_OTHER
|
||||
Time-sharing (TS) scheduling policy.
|
||||
|
@ -68,7 +70,7 @@ First in, first out (FIFO) scheduling policy.
|
|||
.It Dv SCHED_RR
|
||||
Round-robin scheduling policy.
|
||||
.El
|
||||
.It Fl P Ar priority
|
||||
.It Fl P Ar pri
|
||||
Priority which will be set for the process or thread.
|
||||
For all scheduling classes, priority might be set to any value in
|
||||
the range from
|
||||
|
@ -79,9 +81,16 @@ the range from
|
|||
.It Fl p Ar pid
|
||||
The target process which will be affected.
|
||||
If the process has more than one thread, all of them will be affected.
|
||||
.Pp
|
||||
If
|
||||
.Fl p
|
||||
is not given, a command to execute must be given on the command line.
|
||||
.It Fl t Ar lid
|
||||
Thread in the specified process.
|
||||
If specified, only this thread in the process will be affected.
|
||||
May only be specified if
|
||||
.Fl p
|
||||
is also given.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
Show scheduling information about the process whose ID is
|
||||
|
@ -100,6 +109,13 @@ in process whose ID is
|
|||
.Bd -literal -offset indent
|
||||
# schedctl -p 123 -t 1 -A 0,1 -C 2 -P 63
|
||||
.Ed
|
||||
.Pp
|
||||
Run the
|
||||
.Xr top 1
|
||||
command with real-time priority:
|
||||
.Bd -literal -offset indent
|
||||
# schedctl -C SCHED_FIFO top
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr nice 1 ,
|
||||
.Xr getpriority 2 ,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: schedctl.c,v 1.6 2008/04/28 16:52:17 ad Exp $ */
|
||||
/* $NetBSD: schedctl.c,v 1.7 2008/05/25 23:22:16 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008, Mindaugas Rasiukevicius <rmind at NetBSD org>
|
||||
|
@ -33,7 +33,7 @@
|
|||
#include <sys/cdefs.h>
|
||||
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: schedctl.c,v 1.6 2008/04/28 16:52:17 ad Exp $");
|
||||
__RCSID("$NetBSD: schedctl.c,v 1.7 2008/05/25 23:22:16 ad Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -142,29 +142,39 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
/* At least PID must be specified */
|
||||
if (pid == 0)
|
||||
usage();
|
||||
if (pid == 0) {
|
||||
if (argc == 1 || lid != 0)
|
||||
usage();
|
||||
pid = getpid();
|
||||
} else {
|
||||
if (argc != 1)
|
||||
usage();
|
||||
}
|
||||
|
||||
/* Set the scheduling information for thread/process */
|
||||
sched_set(pid, lid, policy, set ? sp : NULL, cpuset);
|
||||
|
||||
/* Show information about each thread */
|
||||
kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open");
|
||||
if (kd == NULL)
|
||||
err(EXIT_FAILURE, "kvm_open");
|
||||
lwp_list = kvm_getlwps(kd, pid, 0, sizeof(struct kinfo_lwp), &count);
|
||||
if (lwp_list == NULL)
|
||||
err(EXIT_FAILURE, "kvm_getlwps");
|
||||
for (lwp = lwp_list, i = 0; i < count; lwp++, i++) {
|
||||
if (lid && lid != lwp->l_lid)
|
||||
continue;
|
||||
thread_info(pid, lwp->l_lid);
|
||||
if (pid != getpid()) {
|
||||
kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open");
|
||||
if (kd == NULL)
|
||||
err(EXIT_FAILURE, "kvm_open");
|
||||
lwp_list = kvm_getlwps(kd, pid, 0, sizeof(struct kinfo_lwp), &count);
|
||||
if (lwp_list == NULL)
|
||||
err(EXIT_FAILURE, "kvm_getlwps");
|
||||
for (lwp = lwp_list, i = 0; i < count; lwp++, i++) {
|
||||
if (lid && lid != lwp->l_lid)
|
||||
continue;
|
||||
thread_info(pid, lwp->l_lid);
|
||||
}
|
||||
kvm_close(kd);
|
||||
free(sp);
|
||||
free(cpuset);
|
||||
return 0;
|
||||
}
|
||||
kvm_close(kd);
|
||||
|
||||
free(sp);
|
||||
free(cpuset);
|
||||
return 0;
|
||||
(void)execvp(argv[optind], argv + optind);
|
||||
err(EXIT_FAILURE, "execvp");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -297,7 +307,8 @@ showcpuset(cpuset_t *cpuset)
|
|||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: %s -p pid [-t lid] [-A processor] "
|
||||
"[-C class] [-P priority]\n", getprogname());
|
||||
|
||||
fprintf(stderr, "usage: %s [-t lid] [-A processor] "
|
||||
"[-C class] [-P priority] {-p pid|command}\n", getprogname());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue