Print the module load time in Linux Device Driver while unloading

In Linux Kernel, the number of timer interrupts per second is defined by 'HZ' variable.

You can get the value of HZ Variable by running the following command.

grep 'CONFIG_HZ=' /boot/config-$(uname -r)

For example, if the value is 250, it means there will be 250 timer interrupts per second.

Linux kernel maintains a global variable 'jiffies' which will be incremented for every timer interrupt. So, for every second, it will be incremented by HZ.

Header File: #include <linux/jiffies.h>

extern unsigned long volatile jiffies;

HZ = (number of ticks)/sec

jiffies = number of ticks

To convert from seconds to unit jiffies: HZ * jiffies

Convert from jiffies to seconds: jiffies/HZ

Code to measure the Driver Load Time:


Output:




Comments

Post a Comment

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

PR, PN and PV Variable in Yocto