#! /sbin/sh
#
# ident "@(#)uttsquantum.sh	1.2 01/04/25 SMI"
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#

# This script adjusts the system's scheduling table for the timesharing
# class.  The intent is to provide better interactive performance.  This
# runs later in the boot process than scripts like rc2.d/S99tsquantum
# and therefore overrides their effects.  S99tsquantum establishes large
# timeslices which are appropriate for non-interactive back-end
# application loads, but since this is a Sun Ray server we want shorter
# timeslices for snappier response times.

############################################################################
##
## Function Definitions 
##

# Tell the world (via stdout by historical precedent, although it should
# really be via stderr) how to invoke this script.
#
# Syntax: 'usage'
#
usage() {
	echo "Usage: $0 { start | stop }"
}


# Adjust the process scheduling rules to provide better interactive
# performance.
#
# Syntax: disptable
#
disptable() {

	# If scheduling adjustments for the timesharing (TS) class are
	# desired then they are held in /etc/opt/SUNWut/disp_table.  If
	# that file exists then feed it to dispadmin(1M).

	TABLE=${SUNWUTETC}/disp_table

	if [ -f ${TABLE} ]; then
                /usr/sbin/dispadmin -c TS -s ${TABLE}
        fi
}


############################################################################
##
## Mainline execution starts here 
##

PATH=/bin:/sbin
export PATH

SUNWUTETC=/etc/opt/SUNWut

# Validate the arguments

if [ $# -ne 1 ] ; then
	usage
	exit 1
fi

case "$1" in

	start)	disptable
		;;

	stop)	# Nothing for us to do, just fall out of the switch
		;;

	*)	usage
		exit 1
		;;
esac

exit 0
