Is there any way to get the cuurent time using C in LINUX. I tried with
clock_get time(). But i'm getting the same time for a particular amout of function call. The code i've used is given below. Is there any way to get the time in an higher resolution.

write()
{
struct timespec time0;
clock_gettime(CLOCK_REALTIME,&time0);
printf("writetime=%lu",time0.tv_nsec);
}
 
main()
{
 ......
for(i=0;i<15;i++)
   write();
 
....
}

Thank You

Is there any way to get the cuurent time using C in LINUX. I tried with
clock_get time(). But i'm getting the same time for a particular amout of function call. The code i've used is given below. Is there any way to get the time in an higher resolution.


write()
{
struct timespec time0;
clock_gettime(CLOCK_REALTIME,&time0);
printf("writetime=%lu",time0.tv_nsec);
}

main()
{
......
for(i=0;i<15;i++)
write();

....
}

Thank You

Here is a list of Linux system calls, you might find something in there: http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html

Also, IF you're a Linux enthusiast I'd recommend getting a good kernel programming book. I've read "Linux Kernel Programming" by by Michael Beck, Harald Bohme, Mirko Dziadzka, and Ulrich Kunitz. Here is a link to the book:
http://www.amazon.com/s/ref=nb_ss_gw/104-1800642-4107953?url=search-alias%3Dstripbooks&field-keywords=Linux+Kernel+Programming&Go.x=8&Go.y=13&Go=Go

Good luck, LamaBot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.