fxdispadmin.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/priocntl.h>
#include <sys/fxpriocntl.h>
#include <errno.h>
#include "dispadmin.h"
/*
* This file contains the class specific code implementing
* the fixed-priority dispadmin sub-command.
*/
#define BASENMSZ 16
extern char *basename();
static void get_fxdptbl(), set_fxdptbl();
static char usage[] = "usage: dispadmin -l\n"
"dispadmin -c FX -g [-r res]\n"
"dispadmin -c FX -s infile\n";
static char cmdpath[256];
int
{
int c;
char *infile;
char *endp;
switch (c) {
case 'l':
lflag++;
break;
case 'c':
fatalerr("error: %s executed for %s class, "
"%s is actually sub-command for FX class\n",
break;
case 'g':
gflag++;
break;
case 'r':
rflag++;
errno = 0;
fatalerr("%s: Can't convert to requested "
"resolution\n", basenm);
break;
case 's':
sflag++;
break;
case '?':
default:
break;
}
}
if (lflag) {
(void) printf("FX\t(Fixed Priority)\n");
return (0);
} else if (gflag) {
if (sflag)
if (rflag == 0)
res = 1000;
return (0);
} else if (sflag) {
if (rflag)
return (0);
} else {
}
return (1);
}
/*
* Retrieve the current fx_dptbl from memory, convert the time quantum
* values to the resolution specified by res and write the table to stdout.
*/
static void
{
int i;
int fxdpsz;
fatalerr("%s: Can't get FX class ID, priocntl system call "
fatalerr("%s: Can't get fx_dptbl size, priocntl system call "
fatalerr("%s: Can't get fx_dptbl, priocntl system call "
(void) printf("# Fixed Priority Dispatcher Configuration\n");
(void) printf("# TIME QUANTUM PRIORITY\n");
(void) printf("# (fx_quantum) LEVEL\n");
for (i = 0; i < fxadmin.fx_ndpents; i++) {
fatalerr("%s: Can't convert to requested "
"resolution\n", basenm);
== -1)
fatalerr("%s: Can't express time quantum in "
"requested resolution,\n"
"try coarser resolution\n", basenm);
}
(void) printf("%10d # %3d\n",
fx_dptbl[i].fx_quantum, i);
}
}
/*
* Read the fx_dptbl values from infile, convert the time quantum values
* to HZ resolution, do a little sanity checking and overwrite the table
* in memory with the values from the file.
*/
static void
set_fxdptbl(char *infile)
{
int i;
int nfxdpents;
char *tokp;
int linenum;
char buf[512];
int wslength;
char *endp;
int len;
fatalerr("%s: Can't get FX class ID, priocntl system call "
fatalerr("%s: Can't get fx_dptbl size, priocntl system call "
if ((fx_dptbl =
linenum = 0;
/*
* Find the first non-blank, non-comment line. A comment line
* is any line with '#' as the first non-white-space character.
*/
do {
linenum++;
/* LINTED - unbounded string specifier */
errno = 0;
i < 0 || *endp != '\0')
fatalerr("%s: Bad RES specification, "
else
res = i;
} else {
fatalerr("%s: Bad RES specification, "
}
}
/*
* The remainder of the input file should contain exactly enough
* non-blank, non-comment lines to fill the table (fx_ndpents lines).
* We assume that any non-blank, non-comment line is data for the
* table and fail if we find more or less than we need.
*/
for (i = 0; i < fxadmin.fx_ndpents; i++) {
/*
* Get the next non-blank, non-comment line.
*/
do {
fatalerr("%s: Too few lines in input table\n",
basenm);
linenum++;
fatalerr("%s: Too few values, line %d of input file\n",
if (fx_dptbl[i].fx_quantum <= 0) {
fatalerr("%s: fx_quantum value out of "
"valid range; line %d of input,\n"
fatalerr("%s: Can't convert specified "
"resolution to ticks\n", basenm);
if ((fx_dptbl[i].fx_quantum =
fatalerr("%s: fx_quantum value out of "
"valid range; line %d of input,\n"
}
fatalerr("%s: Too many values, line %d of input file\n",
}
/*
* We've read enough lines to fill the table. We fail
* if the input file contains any more.
*/
fatalerr("%s: Too many lines in input table\n",
basenm);
}
fatalerr("%s: Can't set fx_dptbl, priocntl system call failed "
}