How to determine the timer frequency in Linux

I need to write a kernel module to calculate the frequency of the Linux kernel (interrupt) timer.

someone told me that I need to use a timer in my module, but I don't know how to do this: (

My ultimate goal is to write the result (frequency) to some file (for example, in: / proc / osfreq /).

=)

+6
source share
2 answers

There are many ways to get the cpu processor frequency:

1. zcat /proc/config.gz |grep CONFIG_HZ # CONFIG_HZ_100 is not set CONFIG_HZ_250=y # CONFIG_HZ_1000 is not set CONFIG_HZ=250 

means 250 Hz

 2. cat /proc/interrupts |grep LOC; sleep 1;cat /proc/interrupts |grep LOC LOC: 43986173 44089526 43986113 44089117 LOC: 43986424 44089777 43986364 44089368 

means that there are 4 logical processors whose frequency: 43986424 - 43986173 ~ = 250.

Alternatively, you can get the var cpu_khz value in proc.c in kernel space.

+8
source

You can simply print the value of the global HZ variable in the module using printk, and check the kernel log after loading the module with $ dmesg, you can find the HZ value.

+1
source

All Articles