From 1f959cb4ab9a35cf1c4e59032a18eddd0f69a16a Mon Sep 17 00:00:00 2001 From: ad Date: Mon, 28 Apr 2008 16:52:17 +0000 Subject: [PATCH] Use symbolic names for -C. --- usr.sbin/schedctl/schedctl.8 | 10 +++++----- usr.sbin/schedctl/schedctl.c | 14 ++++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/usr.sbin/schedctl/schedctl.8 b/usr.sbin/schedctl/schedctl.8 index cbe35c117621..73e105bde6a6 100644 --- a/usr.sbin/schedctl/schedctl.8 +++ b/usr.sbin/schedctl/schedctl.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: schedctl.8,v 1.3 2008/01/26 14:27:42 wiz Exp $ +.\" $NetBSD: schedctl.8,v 1.4 2008/04/28 16:52:17 ad Exp $ .\" .\" Copyright (c) 2008 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -34,7 +34,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 24, 2008 +.Dd April 28, 2008 .Dt SCHEDCTL 8 .Os .Sh NAME @@ -66,13 +66,13 @@ A value of \-1 is used to unset the affinity. .It Fl C Ar class Scheduling class (policy) might be: .Bl -tag -width SCHEDOTHERXX -.It Dv 0: SCHED_OTHER +.It Dv SCHED_OTHER Time-sharing (TS) scheduling policy. The default policy in .Nx . -.It Dv 1: SCHED_FIFO +.It Dv SCHED_FIFO First in, first out (FIFO) scheduling policy. -.It Dv 2: SCHED_RR +.It Dv SCHED_RR Round-robin scheduling policy. .El .It Fl P Ar priority diff --git a/usr.sbin/schedctl/schedctl.c b/usr.sbin/schedctl/schedctl.c index 47031476994d..ea5fdc377e82 100644 --- a/usr.sbin/schedctl/schedctl.c +++ b/usr.sbin/schedctl/schedctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: schedctl.c,v 1.5 2008/03/24 10:33:17 xtraeme Exp $ */ +/* $NetBSD: schedctl.c,v 1.6 2008/04/28 16:52:17 ad Exp $ */ /* * Copyright (c) 2008, Mindaugas Rasiukevicius @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: schedctl.c,v 1.5 2008/03/24 10:33:17 xtraeme Exp $"); +__RCSID("$NetBSD: schedctl.c,v 1.6 2008/04/28 16:52:17 ad Exp $"); #endif #include @@ -53,7 +53,8 @@ __RCSID("$NetBSD: schedctl.c,v 1.5 2008/03/24 10:33:17 xtraeme Exp $"); static const char *class_str[] = { "SCHED_OTHER", "SCHED_FIFO", - "SCHED_RR" + "SCHED_RR", + NULL }; static void sched_set(pid_t, lwpid_t, int, struct sched_param *, cpuset_t *); @@ -110,7 +111,12 @@ main(int argc, char **argv) break; case 'C': /* Scheduling class */ - policy = atoi(optarg); + for (policy = 0; class_str[policy] != NULL; policy++) { + if (strcasecmp(optarg, class_str[policy]) == 0) + break; + } + if (class_str[policy] == NULL) + policy = atoi(optarg); if (policy < SCHED_OTHER || policy > SCHED_RR) { fprintf(stderr, "%s: invalid scheduling class\n",