start_rt_publish.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. #program path or install dir
  3. IF=enp0s8
  4. CPU_NR=3
  5. PRIO=90
  6. OLDDIR=$(pwd)
  7. reset() {
  8. #standard on most systems. ondemand -> Dynamic CPU-Freq.
  9. echo ondemand >/sys/devices/system/cpu/cpu$CPU_NR/cpufreq/scaling_governor
  10. cd /sys/devices/system/cpu/cpu$CPU_NR/cpuidle
  11. for i in *
  12. do
  13. #~disable sleep state
  14. echo 0 >$i/disable
  15. done
  16. phy=$IF #get interface name
  17. #get pid's from interface irq
  18. for i in `ps ax | grep -v grep | grep $phy | sed "s/^ //" | cut -d" " -f1`
  19. do
  20. #retrive or set a process's CPU affinity
  21. taskset -pc 0-$CPU_NR $i >/dev/null
  22. #manipulate the real-time attributes of a process -p priority -f scheduling policy to SCHED_FIFO
  23. chrt -pf 50 $i
  24. done
  25. #distribute hardware interrupts across processsors on a muliprocessor system
  26. systemctl start irqbalance
  27. }
  28. trap reset ERR
  29. systemctl stop irqbalance
  30. phy=$IF
  31. for i in `ps ax | grep -v grep | grep $phy | sed "s/^ //" | cut -d" " -f1`
  32. do
  33. taskset -pc $CPU_NR $i >/dev/null
  34. chrt -pf $PRIO $i
  35. done
  36. cd /sys/devices/system/cpu/cpu$CPU_NR/cpuidle
  37. for i in `ls -1r`
  38. do
  39. echo 1 >$i/disable
  40. done
  41. echo performance >/sys/devices/system/cpu/cpu$CPU_NR/cpufreq/scaling_governor
  42. cd $OLDDIR
  43. taskset -c $CPU_NR chrt -f $PRIO $1