home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- #
- # Copyright (c) 2003 SuSE Linux AG, Nuernberg, Germany.
- # All rights reserved.
- #
- # /etc/init.d/boot.sched
- #
- ### BEGIN INIT INFO
- # Provides: boot.sched
- # Default-Start: B
- # Default-Stop:
- # Description: sets the scheduling timeslices
- ### END INIT INFO
-
- . /etc/rc.status
- test -r /etc/sysconfig/kernel || exit 6
- . /etc/sysconfig/kernel
-
- rc_reset
-
- case "$1" in
- start)
- echo -n "Setting scheduling timeslices "
- # Configured?
- if test -z "$SCHED_MINTIMESLICE" -o -z "$SCHED_MAXTIMESLICE"; then
- rc_failed 6
- # Sanity?
- elif test $((3*$SCHED_MINTIMESLICE)) -gt $SCHED_MAXTIMESLICE; then
- echo -n "3*$SCHED_MINTIMESLICE > $SCHED_MAXTIMESLICE"
- rc_failed 1
- # Kernel support?
- elif test ! -r /proc/sys/kernel/min-timeslice; then
- echo -n "not supported by kernel ";
- rc_failed 3
- elif test ! -r /proc/sys/kernel/HZ; then
- echo -n "kernel HZ unknown "
- rc_failed 3
- # Go!
- else
- # Make sure timeslice is at least as large as the minimum
- read HZ < /proc/sys/kernel/HZ
- MINSLICE=$((1000000/$HZ))
- if test $MINSLICE -gt $SCHED_MINTIMESLICE; then
- # Scale max timeslice
- MAXSLICE=$(($SCHED_MAXTIMESLICE*$MINSLICE/$SCHED_MINTIMESLICE))
- echo -n "$SCHED_MINTIMESLICE->$MINSLICE $SCHED_MAXTIMESLICE->$MAXSLICE"
- SCHED_MINTIMESLICE=$MINSLICE
- SCHED_MAXTIMESLICE=$MAXSLICE
- else
- echo -n "$SCHED_MINTIMESLICE $SCHED_MAXTIMESLICE "
- fi
- echo $SCHED_MINTIMESLICE > /proc/sys/kernel/min-timeslice
- rc_status
- if test -e /proc/sys/kernel/def-timeslice; then
- echo $((($SCHED_MAXTIMESLICE+$MINSLICE)/2)) > /proc/sys/kernel/def-timeslice
- rc_status
- else
- echo $SCHED_MAXTIMESLICE > /proc/sys/kernel/max-timeslice
- rc_status
- fi
- fi
- true
- rc_status -v
- ;;
-
- stop|restart)
- # skip / nothing to do
- ;;
- status)
- rc_failed 4
- rc_status -v
- ;;
- *)
- echo "Usage: $0 {start|stop|status|restart}"
- exit 1
- ;;
- esac
-
- rc_exit
-
-