Linux HZ checker

22 01 2008

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:

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’`
echo “HZ:$C”

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;




4 responses

10 03 2009

The script wouldn’t work for me. So I used awk instead of cut. It might be a little simpler also.

while [ 1 ]; do
A=`cat /proc/interrupts | grep timer | awk ‘{ print $2 }’`
sleep 1
B=`cat /proc/interrupts | grep timer | awk ‘{ print $2 }’`
echo “HZ:$C”

5 06 2010
Jules Simon

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`))

18 09 2012
How to check HZ in the terminal? - feed99

[…] have seen this But the script seems not to work. Does anyway know an easy way to chech “HZ” in the […]

3 01 2019
linux - Comment vérifier HZ dans le terminal?

[…] vu cette Mais le script ne semble pas fonctionner. Fait quand même connaître un moyen facile de vérifier […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: