/*
* 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 <errno.h>
#include <sys/priocntl.h>
#include <sys/iapriocntl.h>
#include "dispadmin.h"
/*
* This file contains the class specific code implementing
* the interactive dispadmin sub-command.
*/
extern char *basename();
static void get_iadptbl(), set_iadptbl();
static char usage[] =
"usage: dispadmin -l\n\
dispadmin -c IA -g [-r res]\n\
dispadmin -c IA -s infile\n";
int
{
extern char *optarg;
int c;
char *infile;
switch (c) {
case 'l':
lflag++;
break;
case 'c':
fatalerr("error: %s executed for %s class, "
"%s is actually sub-command for IA class\n",
break;
case 'g':
gflag++;
break;
case 'r':
rflag++;
break;
case 's':
sflag++;
break;
case '?':
default:
break;
}
}
if (lflag) {
(void) printf("IA\t(Interactive)\n");
return (0);
} else if (gflag) {
if (rflag == 0)
res = 1000;
return (0);
} else if (sflag) {
return (0);
} else {
}
return (1);
}
/*
* Retrieve the current ia_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 iadpsz;
fatalerr("%s: Can't get IA class ID, priocntl system "
"call failed with errno %d\n",
fatalerr("%s: Can't get ia_dptbl size, priocntl system "
"call failed with errno %d\n",
fatalerr("%s: Can't get ia_dptbl, priocntl system call "
"call failed with errno %d\n",
(void) printf("# Interactive Dispatcher Configuration\n");
(void) printf("# ia_quantum ia_tqexp ia_slpret ia_maxwait ia_lwait \
PRIORITY LEVEL\n");
for (i = 0; i < iaadmin.ia_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("%10ld%10d%10d%12d%10d # %3d\n",
}
}
/*
* Read the ia_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
char *infile;
{
int i;
int niadpents;
char *tokp;
int linenum;
int wslength;
fatalerr("%s: Can't get IA class ID, priocntl system "
fatalerr("%s: Can't get ia_dptbl size, priocntl system "
if ((ia_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++;
fatalerr("%s: Bad RES specification, line %d of input file\n",
fatalerr("%s: Bad RES specification, \
fatalerr("%s: Bad RES specification, \
fatalerr("%s: Bad RES specification, \
fatalerr("%s: Bad RES specification, \
if (tokp[0] == '-')
fatalerr("%s: Bad RES specification, \
fatalerr("%s: Bad RES specification, \
fatalerr("%s: Bad RES specification, \
fatalerr("%s: Bad RES specification, \
fatalerr("%s: Bad RES specification, \
fatalerr("%s: Bad RES specification, \
if (tokp[0] == '-')
fatalerr("%s: Bad RES specification, \
}
} else {
fatalerr("%s: Bad RES specification, line %d of input file\n",
}
/*
* The remainder of the input file should contain exactly enough
* non-blank, non-comment lines to fill the table (ia_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 < iaadmin.ia_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",
fatalerr("%s: Can't convert specified \
resolution to ticks\n", basenm);
== -1)
fatalerr("%s: ia_quantum value out of "
"valid range; line %d of input,\n"
"table not overwritten\n",
} else {
}
if (ia_dptbl[i].ia_quantum <= 0)
fatalerr("%s: ia_quantum value out of valid range; "
"line %d of input,\ntable not overwritten\n",
fatalerr("%s: Too few values, line %d of input file\n",
fatalerr("%s: ia_tqexp value out of valid range; "
"line %d of input,\ntable not overwritten\n",
fatalerr("%s: Too few values, line %d of input file\n",
fatalerr("%s: ia_slpret value out of valid range; "
"line %d of input,\ntable not overwritten\n",
fatalerr("%s: Too few values, line %d of input file\n",
if (ia_dptbl[i].ia_maxwait < 0)
fatalerr("%s: ia_maxwait value out of valid range; "
"line %d of input,\ntable not overwritten\n",
fatalerr("%s: Too few values, line %d of input file\n",
fatalerr("%s: ia_lwait value out of valid range; "
"line %d of input,\ntable not overwritten\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 ia_dptbl, priocntl system call \
}