summaryrefslogtreecommitdiffstats
path: root/projectroot/etc/init.d/rt-set-bandwidth
blob: 4c0f7a503191cd31ec592c12c8fd904bbf636d12 (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
#! /bin/sh
#
# set bandwidth throttling of rt
# this default script will disable it since it seems the right choice for embedded systems.
# use this file as a template for custom settings (think about the period, too) and put it 
# into projectroot.

set -e
runtime=/proc/sys/kernel/sched_rt_runtime_us
runtime_orig=/var/run/sched_rt_runtime_us.orig

case $1 in
	start)
		if [ -f "${runtime}" -a -w "${runtime}" ]; then
			cp "${runtime}" "${runtime_orig}"
			# Customize your value(s) here
			echo "-1" > "${runtime}"
		else
			echo "WARNING: Disabling RT-bandwidth was requested, but there are access problems with ${runtime}!"
			exit 1
		fi
		;;
	stop)
		if [ -f "${runtime_orig}" ]; then
			cat "${runtime_orig}" > "${runtime}"
		else
			echo "WARNING: Restoring RT-bandwidth was requested, but original value was not found!"
		fi
		;;
	*)
		echo "Usage: $0 {start|stop}"
		exit 1
		;;
esac

exit 0