c - Jiffies - how to calculate seconds elapsed? -
i have piece of code, want calculate time in seconds.. though getting time in jiffies, how can convert in seconds?
here kernel code:
#include <linux/module.h> #include <linux/kernel.h> #include <linux/jiffies.h> #include <linux/timer.h> unsigned long js, je, tet; int netblock_init_module(void){ js = jiffies; printk("\n[jiffies start time : %lu]\nmodule started.\n", js); return 0; } void netblock_cleanup_module(void) { je = jiffies; printk("\n[jiffies end time : %lu]\nmodule removed.\n", je); tet = je - js; printk("\nend time [%lu] - start time [%lu]: \ntotlal elapsed time [%lu]\n",js,je, tet); } module_init(netblock_init_module); module_exit(netblock_cleanup_module); module_license("gpl"); module_description("jiffies example"); module_author("raheel"); output getting this:
$insmod jiffexample.ko
[jiffies start time : 13363583]
module started
$rmmod jiffexample.ko
[jiffies end time : 13361588]
module removed.
end time 13361588 - start time 1336358
total elapsed time [1605]
now want converted time in seconds.. how possible convert elapsed time 1605 in seconds? or alternatively can please tell me how many jiffies in second?
from http://www.kernel.org/doc/man-pages/online/pages/man7/time.7.html:
the size of jiffy determined value of kernel constant hz.
the value of hz varies across kernel versions , hardware platforms. on i386 situation follows: on kernels , including 2.4.x, hz 100, giving jiffy value of 0.01 seconds; starting 2.6.0, hz raised 1000, giving jiffy of 0.001 seconds. since kernel 2.6.13, hz value kernel configuration parameter , can 100, 250 (the default) or 1000, yielding jiffies value of, respectively, 0.01, 0.004, or 0.001 seconds. since kernel 2.6.20, further frequency available: 300, number divides evenly common video frame rates (pal, 25 hz; ntsc, 30 hz).
just divide hz.
Comments
Post a Comment