eccolo qui. Ancora più semplice del previsto:antonellocaroli ha scritto:urge esempio pratico.
Codice: Seleziona tutto
#!/bin/bash
# per prima cosa eseguo 'ps' ed uso il suo output
# per ottenere un array con i pids di mpd:
#
mpd_tid=($(ps -C mpd -L --no-headers -o tid))
# poi verifico che il numero di threads sia quello previsto:
#
if [ ${#mpd_tid} -lt 4 ]; then
echo -e "\nToo few (${#mpd_tid}) threads found: is mpd running?\nAbort."
exit 1
elif [ ${#mpd_tid} -gt 4 ]; then
echo -e "\nSomething is wrong: too many ((${#mpd_tid})) threads found!\nAbort."
exit 2
fi
# else -> ok, expected number of threads
# set desired policies & priorities:
# chrt -v -r -p 1 ${mpd_tid[0]} # main
# chrt -v -r -p 1 ${mpd_tid[1]} # update
chrt -v -r -p 60 ${mpd_tid[2]} # player
chrt -v -r -p 60 ${mpd_tid[3]} # decoder
chrt -v -r -p 60 ${mpd_tid[4]} # output
# use somthing like:
# ps -C mpd -L -o tid,cmd,nlwp,ni,pri,cls,rtprio
# to check!
# Hint: see the relevant man pages!
# man bash
# man ps
# man chrt