summarylogtreecommitdiffstats
path: root/rtapp
blob: a9a0f60f0d6e33af0c21ffe7f69275563dd159f8 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash

# Copyright Piero Olmeda - AudioLinux  <audiolinux AT fastmail DOT fm>
# https://www.audio-linux.com

# License: custom - All rights reserved

source /etc/rtirq.conf
high=$RTIRQ_PRIO_HIGH
step=$RTIRQ_PRIO_DECR
list=`echo $RTIRQ_NAME_LIST | wc -w`
min=$(( $high - $(($step * $list)) ))
source /etc/rtapp/rtapp.conf
mode=$MODE
app=$APPLICATIONS
max=$MAX_PRIORITY

update_priority () {
                for WORD in $app
                do
                (pidof $WORD 1>/dev/null && chrt -f -a -p $fifo_app $(pidof $WORD)) || echo $WORD" is not running"
                done
} 

update_priority_dec () {
                for WORD in $app
                do
                    if [[ "$(pidof $WORD)" ]]
                    then                                           
                      chrt -f -a -p $fifo_app $(pidof $WORD)
                      fifo_app=$(( $fifo_app - $step )) 
                    fi
                done
}

case $mode in

manual)
                echo "manual"
                fifo_app=$max
                if [[ $fifo_app -le $min ]]; then
                    update_priority
                else
                    echo "The priority is too high"
            
                fi
        ;;

auto)           
                echo "auto"
                fifo_app=$(( $high - $(($step * $list)) ))
                update_priority
        ;;
        
autodec)

                echo "autodec"
                fifo_app=$(( $high - $(($step * $list)) ))
                update_priority_dec
        ;;

manualdec)

                echo "manual"
                fifo_app=$max
                if [[ $fifo_app -le $min ]]; then
                    update_priority_dec
                else
                    echo "The priority is too high"
            
                fi
        ;;
        
esac