Last active
March 20, 2020 03:18
-
-
Save bugcy013/12c15414e7e2c6e9cf6813c36b727f1a to your computer and use it in GitHub Desktop.
Change Process scheduling to Realtime scheduler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| print_usage() { | |
| echo "Usage: $( basename $1 ) <process name> <SCHED_FIFO | SCHED_RR> <priority (1-99)>" | |
| } | |
| if [ $# != 3 ]; then | |
| print_usage $0 | |
| exit 1 | |
| fi | |
| process_name=$1 | |
| sched_policy=$2 | |
| let priority=$3 | |
| if [ "$sched_policy" == "SCHED_FIFO" ]; then | |
| sched_flag="-f" | |
| elif [ "$sched_policy" == "SCHED_RR" ]; then | |
| sched_flag="-r" | |
| else | |
| print_usage $0 | |
| exit 2 | |
| fi | |
| if [ $priority -lt 1 ] || [ $priority -gt 99 ] | |
| then | |
| print_usage $0 | |
| exit 3 | |
| fi | |
| PIDS=$( ps -e | grep $process_name | grep -o '^[[:space:]]*[[:digit:]]\+\>' ) | |
| for i in $PIDS; do | |
| echo "$1 PID: $i" | |
| chrt $sched_flag -p $priority $i | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment