a.c:
#include "a.h"
double GetTimeStamp()
{
struct timespec start;
if((clock_gettime( CLOCK_REALTIME, &start)) == -1 )
{
perror("clock gettime\n");
}
/* I am calculating the Clock granularity here the granularity is basically how long that timer interrupt
* will last while it's processing the background task.*/
//micro seconds output
return (1e3 * start.tv_sec + start.tv_nsec * 1e-3);
}
int a()
{
intr_rx_time = GetTimeStamp();
IPLatency = intr_rx_time;
}
a.h:
a();
double intr_rx_time, IPLatency;
b.c:
#include "a.h"
extern double IPLatency;
uint32 ipLatency;
int main()
{
ipLatency = (uint32)IPLatency;
printf("Current IP Latency microseconds: %ld\n", ipLatency);
}
In the above : I am calculating a timestamp from a.c program. Later I am reading the calcualted timestamp value in b.c program as shown above. But I am getting the output as 0 in b.c program. what is the error in the above program ?? could someone please help .