I would like to understand how can I implement elapsed time using jiffies in C. Let's suppose that I have a series of instructions
#include <linux/jiffies.h>
unsigned long js,je,diff;
/***Start Time***/
/*Series of instructions*/
/***End Time***/
Using jiffies, what must I write on my code? Is it right to write so?
#include <linux/jiffies.h>
unsigned long js,je,diff;
unsigned int diffusec;
js = jiffies; /***Start Time***/
/*Series of instructions*/
je = jiffies; /***End Time***/
diff = je - js;
diffusec = jiffies_to_usecs(diff);
Is it right? Using jiffies is better than using getnstimeofday function?
You can do something like this :
Since you are working on ARM arch, it may help to check the available resolution of your system timer by insmoding a kernel module that prints on dmesg the resolution:
If the resolution is the number of ns in a jiffies period, then you are a bit limited on your platform, otherwise, you can think of using the hrtimers to monitor the processing time.
To compile the previous code : you can reuse the following Makefile :
Hope that helps. Aymen.