HZ defined how many ticks the internal timer interrupt in 1sec, which means the number of jiffies count in 1 sec.
Different architecture/machine may have different HZ value, you can check using this script from the timer interrupt:
#!/bin/sh
while [ 1 ]; do
A=`cat /proc/interrupts | grep timer | cut -d ‘:’ -f 2 |sed -e ‘s/[^0-9]//g’`
sleep 1
B=`cat /proc/interrupts | grep timer | cut -d ‘:’ -f 2 |sed -e ‘s/[^0-9]//g’`
C=$(($B-$A));
echo “HZ:$C”
done
it is around 250 in my desktop running 2.6, but 100 in my mips 2.4 embedded board.
Sometimes we may need to know the time in seconds from jiffies in kernel.
time(sec) = jiffies/HZ;
The script wouldn’t work for me. So I used awk instead of cut. It might be a little simpler also.
#!/bin/sh
while [ 1 ]; do
A=`cat /proc/interrupts | grep timer | awk ‘{ print $2 }’`
sleep 1
B=`cat /proc/interrupts | grep timer | awk ‘{ print $2 }’`
C=$(($B-$A));
echo “HZ:$C”
done
Rule #1 of shell scripting: cat is NEVER necessary unless it’s actually used for concatenating. If you’re doing cat xxxxx | zzzz, you’re doint it wrong.
#37: Don’t pipe grep into awk. Awk can do regular expressions.
Try this instead:
i=/proc/interrupts;s=’/l timer/{print $2}’;echo $((-`awk “$s”<$i;sleep 1`+`awk "$s"<$i`))
[…] have seen this https://kaasxxx.wordpress.com/2008/01/22/linux-hz-checker/ But the script seems not to work. Does anyway know an easy way to chech “HZ” in the […]
[…] vu cette https://kaasxxx.wordpress.com/2008/01/22/linux-hz-checker/ Mais le script ne semble pas fonctionner. Fait quand même connaître un moyen facile de vérifier […]
[…] have seen this https://kaasxxx.wordpress.com/2008/01/22/linux-hz-checker/ But the script seems not to work. Does anyway know an easy way to check “HZ” in the […]