c++ - How to make sure nanosleep working in my system in linux -
i have checked system supporting microsec precision how make system support nanosec precision using boost timer able print current time in microsec precision print current time in microsec
now when check whether nanosleep / usleep working or not, run program .
here program1
print current time in microsec usleep(1); // sleep 1 microsec print current time in microsec
here output
01:43:38.799150 01:43:38.799393
when run program2
struct timespec delay; delay.tv_sec = 0; delay.tv_nsec = 1000; print current time in microsec nanosleep(&delay, null); print current time in microsec
i got output
01:48:25.919269 01:48:25.919838
i expecting 1 microsec difference in current time whereas getting more 100 microsec difference. what's reason?
i doubt whether system execute usleep/nanosleep although usleep(1) call indirectly nanosleep(1000)
i using g++, linux. or insight great , in advance .
Comments
Post a Comment