Debian Codegraph @

debian/scripts/quantumpriority.sh

raw
1 #!/bin/sh
2
3 # set priority according to quantum
4 set -e
5
6 # default quantum priority is above all priority
7 DEFAULT_PRIORITY=10000
8
9 if test "x$DEFAULTQUANTUMDEPTH" = x; then
10 echo "No default quantum exit" > /dev/stderr;
11 exit 1;
12 fi
13
14 if test "x$1" = x; then
15 echo "No quantum exit" > /dev/stderr;
16 exit 1;
17 fi
18
19
20 QUANTUM_PART=$(set -e;echo -n "$1" | sed -r 's/q?([[:digit:]]*)(HDRI)?/\1/gi')
21 HDRI_STR=$(set -e;echo -n "$1" | sed -e 's/\(.*\)/\L\1/')
22 HDRI=$(set -e;case "$HDRI_STR" in *hdri) echo 'yes';; *) echo 'no' ;; esac)
23
24 if test "x$1" = "x$DEFAULTQUANTUMDEPTH"; then
25 echo -n $DEFAULT_PRIORITY
26 exit 0;
27 fi
28
29 # hdri is slower divide
30 if test "x$HDRI" = "xyes"; then
31 PRIO_OFFSET=100;
32 else
33 PRIO_OFFSET=1000;
34 fi;
35
36 # larger is slower
37 case $QUANTUM_PART
38 in 8)
39 BASE_PRIO=4;;
40 16)
41 BASE_PRIO=3;;
42 32)
43 BASE_PRIO=2;;
44 64)
45 BASE_PRIO=1;;
46 *)
47 echo "unknown quantum exit" > /dev/stderr;
48 exit 1;
49 ;;
50 esac
51
52 echo -n $(($BASE_PRIO*100+$PRIO_OFFSET))
53
54 exit 0;