I have seen this http://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 terminal in Linux?
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- How to account for clock offsets in a distributed
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
There are many different approaches to get a hint on what your settings are. On some single-core systems this trick is handy:
It shows you the amount of ticks there were during the 10 sec. sleep. Here about 100'000. Divide by 10 gives about 10'000 HZ.
This might get confusing on multicore systems, as it will be a per core list.
Another option will be to check if you can get a hand on the original kernel config. It would be stored in
Unpack it and open the file. Search for parts that look similar to
Just to warn you; 10'000 is way off normal settings. Experimental setup.
The value of HZ can be determined like so:
Any of the compile time options of the running kernel can be gleamed using
getconf
. Keep in mind that HZ is configurable:As is typically the case you may need to trim the
_SC_
bit off of the variable name shown in the man pages when inquiring about it usinggetconf
.There's no uniform answer to this questions, as in some cases your kernel may be compiled "tickless" and not use a regular timer interrupt at all. But if you're on a traditional kernel and a traditional distro, you can find the current kernel's
.config
file under /boot with something likegrep 'CONFIG_HZ=' /boot/config-$(uname -r)
.In my C programs I use the start time of a process and the uptime and more for some value calculations at runtime.
In Bash the HZ calculation would look like e.g.
Means: Take the 22nd value of uptime and divide it by the start time of the "self" process.
EDIT:
Yes, user1530335, this is correct. Additional info about the stat file can be taken from the man page proc(5). Here the field "starttime" is described as "the time in jiffies the process started after system boot".
Yes, and mostly (Intel arch) it will be 100. Older rare "preempt" kernels sometimes had 1000 even on Intel. Other values could be: