aboutsummaryrefslogtreecommitdiffstats
path: root/setsched
blob: df3855872cfe9a859f9671f9149d97e671e74538 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
#
# setsched: facilitate changing the active scheduler plugin.

ADIR=/proc/litmus/active_plugin
PDIR=/proc/litmus/plugins/loaded
DIALOG=`which dialog 2> /dev/null`

CHOICE=$1

if [ ! -e $ADIR ]; then
    KERN=`uname -s -r`
    echo "Error: LITMUS^RT interface not found on $KERN!"
    echo "Are you sure you booted the correct kernel?"
    echo "Is the /proc filesystem mounted correctly?"
    exit 1
fi

ACTIVE=`cat $ADIR`

if [ -z "$1" ]; then
    # Check for presence of dialog, some distros don't install it by default.
    if [ -z "$DIALOG" ]; then
	echo "Error: The dialog utility cannot be found."
	echo "       Please install the required package (dialog on Ubuntu),"
	echo "       or specify the desired plugin as a commandline argument,"
	echo "       e.g., 'setsched GSN-EDF'."
	exit 2
    fi
    TMP=`mktemp`
    (awk "{print \$1 \" 'Plugin'\"}" $PDIR | \
    xargs $DIALOG --title "Select Plugin" --backtitle "Current: $ACTIVE"  \
	--cancel-label "Cancel" --ok-label "Select Plugin" \
	--menu "Select a new plugin to run: " 15 60 6) 2> $TMP
    OK=$?
    clear
    if [ "$OK" != "0" ]; then
	exit 0;
    fi
    CHOICE=`cat $TMP`
    rm $TMP
fi


echo "$CHOICE" > $ADIR 2> /dev/null || \
    echo "Error: Cannot write to $ADIR. Do you have root privileges?"

ACTIVE=`cat $ADIR`

if [ "$ACTIVE" != "$CHOICE" ]; then
    echo "Error: Setting new plugin failed."
    echo "Are there any active real-time tasks?"
    exit 1
fi