Emadpres
Emadpres

Reputation: 3737

How to determine timer frequency in linux

I need to write a kernel module to calculate Linux Kernel Timer (Interrupt) Frequency .

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

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

=)

Upvotes: 7

Views: 9159

Answers (2)

harry
harry

Reputation: 11

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

Upvotes: 1

shiwenlu518
shiwenlu518

Reputation: 466

There are many ways to get the cpu's time 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 there are 4 logic CPUs, whose frequency is: 43986424 - 43986173 ~=250.

Also, you can get value of var cpu_khz in proc.c at kernel space.

Upvotes: 14

Related Questions