Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20703 Discussions

Time on Ecos (or Qemu )

Altera_Forum
Honored Contributor II
993 Views

I'm working with real time operating system Ecos. I run this code on ubuntu : 

 

 

# include <stdio.h> # include <sys/time.h> # include <unistd.h> static int tv_diff(struct timeval *t1, struct timeval *t2) { return (t1->tv_sec - t2->tv_sec) * 1000 + (t1->tv_usec - t2->tv_usec) / 1000; } int main(void) { struct timespec ts; struct timeval tv1, tv2; printf("Hello, eCos !\n"); clock_gettime(1, &ts); tv1.tv_sec = ts.tv_sec; tv1.tv_usec = ts.tv_nsec / 1000; printf("Time: %ld \n", tv1.tv_sec); sleep(10); clock_gettime(1, &ts); tv2.tv_sec = ts.tv_sec; tv2.tv_usec = ts.tv_nsec / 1000; printf("Time: %ld \n", tv2.tv_sec); printf("diff Time: %d \n", tv_diff(&tv2, &tv1)); return 0; }  

 

and it worked properly : 

 

 

root@ubuntu:/home/feres/Bureau# ./amin 

Hello, eCos ! 

Time: 45417  

Time: 45427  

diff Time: 10000 

 

 

But when i run it on Ecos ( wich it work on Qemu ) it give me this results: 

 

 

Hello, eCos ! 

Time: 0  

Time: 0  

diff Time: 0  

 

 

Is there any missing package on Ecos (or Qemu) or is there any specific commande to get time on Ecos (or Qemu)?
0 Kudos
0 Replies
Reply