xref: /titanic_52/usr/src/cmd/dispadmin/svc-scheduler (revision c7158ae983f5a04c4a998f468ecefba6d23ba721)
1#!/sbin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License, Version 1.0 only
7# (the "License").  You may not use this file except in compliance
8# with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or http://www.opensolaris.org/os/licensing.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23#
24# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27# ident	"%Z%%M%	%I%	%E% SMI"
28#
29# Set default scheduling class
30#
31
32. /lib/svc/share/smf_include.sh
33
34[ -f /etc/dispadmin.conf ] || exit $SMF_EXIT_OK
35if  [ -x /usr/sbin/dispadmin ] && [ -x /usr/bin/priocntl ]; then
36	ERROR="$0: cannot set default scheduling class to "
37	DISPADMIN_D=`/usr/sbin/dispadmin -d`
38
39	if [ $? -eq 0 ]; then
40		#
41		# Inform the kernel about the default scheduling class.
42		#
43		/usr/sbin/dispadmin -u
44
45		DEFAULT_SCHEDULER=`echo $DISPADMIN_D | /usr/bin/cut -f1 -d' '`
46
47		/usr/bin/priocntl -s -c $DEFAULT_SCHEDULER -i all
48		if [ $? -ne 0 ]; then
49			echo $ERROR $DEFAULT_SCHEDULER
50			exit $SMF_EXIT_ERR_FATAL
51		else
52			#
53			# Also need to move init process explicitly
54			# because it was ignored by "-i all".
55			#
56			/usr/bin/priocntl -s -c $DEFAULT_SCHEDULER -i pid 1
57			if [ $? -ne 0 ]; then
58				echo $ERROR $DEFAULT_SCHEDULER
59				exit $SMF_EXIT_ERR_FATAL
60			fi
61		fi
62	else
63		#
64		# Default scheduling class from dispadmin.conf is
65		# invalid or not available.
66		#
67		exit $SMF_EXIT_ERR_CONFIG
68	fi
69else
70	# dispadmin or priocntl commands can't be executed
71	echo "$0: cannot execute command"
72	exit $SMF_EXIT_ERR_FATAL
73fi
74exit $SMF_EXIT_OK
75