I want to use clock_nanosleep for waiting of 1 microsec.. As far as I understand, I have to give an absolute time as input. Is the following code okay in this case?
<
@ryanyuyu
sample code::
void mysleep_ms(int milisec) { struct timespec res; res.tv_sec = milisec/1000; res.tv_nsec = (milisec*1000000) % 1000000000; clock_nanosleep(CLOCK_MONOTONIC, 0, &res, NULL); }
this is monotonic clock based sleep function. please refer it.