home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / rescue / etc / init.d / boot.sched < prev    next >
Text File  |  2006-11-29  |  2KB  |  81 lines

  1. #! /bin/sh
  2. #
  3. # Copyright (c) 2003 SuSE Linux AG, Nuernberg, Germany.
  4. # All rights reserved.
  5. #
  6. # /etc/init.d/boot.sched
  7. #
  8. ### BEGIN INIT INFO
  9. # Provides:          boot.sched
  10. # Default-Start:     B
  11. # Default-Stop:
  12. # Description:       sets the scheduling timeslices
  13. ### END INIT INFO
  14.  
  15. . /etc/rc.status
  16. test -r /etc/sysconfig/kernel || exit 6
  17. . /etc/sysconfig/kernel
  18.  
  19. rc_reset
  20.  
  21. case "$1" in
  22.   start)
  23.     echo -n "Setting scheduling timeslices "
  24.     # Configured?
  25.     if test -z "$SCHED_MINTIMESLICE" -o -z "$SCHED_MAXTIMESLICE"; then
  26.         rc_failed 6
  27.     # Sanity?
  28.     elif test $((3*$SCHED_MINTIMESLICE)) -gt $SCHED_MAXTIMESLICE; then
  29.         echo -n "3*$SCHED_MINTIMESLICE > $SCHED_MAXTIMESLICE"
  30.         rc_failed 1
  31.     # Kernel support?
  32.     elif test ! -r /proc/sys/kernel/min-timeslice; then
  33.         echo -n "not supported by kernel ";
  34.         rc_failed 3
  35.     elif test ! -r /proc/sys/kernel/HZ; then
  36.         echo -n "kernel HZ unknown "
  37.         rc_failed 3
  38.     # Go!
  39.     else
  40.         # Make sure timeslice is at least as large as the minimum
  41.         read HZ < /proc/sys/kernel/HZ
  42.         MINSLICE=$((1000000/$HZ))
  43.         if test $MINSLICE -gt $SCHED_MINTIMESLICE; then
  44.             # Scale max timeslice
  45.             MAXSLICE=$(($SCHED_MAXTIMESLICE*$MINSLICE/$SCHED_MINTIMESLICE))
  46.             echo -n "$SCHED_MINTIMESLICE->$MINSLICE $SCHED_MAXTIMESLICE->$MAXSLICE"
  47.             SCHED_MINTIMESLICE=$MINSLICE
  48.             SCHED_MAXTIMESLICE=$MAXSLICE
  49.         else
  50.             echo -n "$SCHED_MINTIMESLICE $SCHED_MAXTIMESLICE "
  51.         fi    
  52.         echo $SCHED_MINTIMESLICE > /proc/sys/kernel/min-timeslice
  53.         rc_status
  54.         if test -e /proc/sys/kernel/def-timeslice; then
  55.             echo $((($SCHED_MAXTIMESLICE+$MINSLICE)/2)) > /proc/sys/kernel/def-timeslice
  56.             rc_status
  57.         else    
  58.             echo $SCHED_MAXTIMESLICE > /proc/sys/kernel/max-timeslice
  59.             rc_status
  60.         fi
  61.     fi
  62.     true
  63.     rc_status -v
  64.     ;;
  65.     
  66.     stop|restart)
  67.         # skip / nothing to do
  68.     ;;
  69.     status)
  70.     rc_failed 4
  71.     rc_status -v
  72.     ;;
  73.     *)
  74.     echo "Usage: $0 {start|stop|status|restart}"
  75.     exit 1
  76.     ;;
  77. esac
  78.  
  79. rc_exit
  80.  
  81.