Skip to content
Advertisement

Tag: gettimeofday

Understanding the output of gettimeofday

I am trying to understand the precision of the gettimeofday() system call. Here’s my program: The output if I run this program (./a.out 10) is, The seconds column seems to reconcile with the sleep of 1 secs. Can someone please explain what’s going on with the values in micro seconds column? It looks like the jumps from sleep to sleep

Control loop time with usleep

I try to make sure the execution time of each loop to 10ms with usleep , but sometimes it exceeds 10ms. I have no idea how to solve this problem, is it proper to use usleep and gettimeofday in this case? Please help my find out what i missed. Result: 0.0127289 0.0136499 0.0151598 0.0114031 0.014801 Answer To keep the loop

Advertisement