Delay by 1 microsecond in C MIPS Environment -
i'm trying port u8glib (graphics library) mips processor, openwrt router. here's example in arm environment. as such, 1 of routines must implement is: delay_micro_seconds(uint32_t us) since high resolution unit of time, how can reliably in environment? i've tried following, i'm not sure how validate it: nanosleep((struct timespec[]){{0, 1000}}, null); how can validate approach? if bad approach, how reliably delay 1 microsecond in c? edit: i've tried this, i'm getting strange output, expect difference between 2 print s 1000*10 iterations = 10,000 , closer 670,000 nanoseconds: int main(int argc, char **argv) { long res, resb; struct timespec ts, tsb; int i; res = clock_gettime(clock_realtime, &ts); for(i=0;i<10;i++){ nanosleep((struct timespec[]){{0,1000}}, null); } resb = clock_gettime(clock_realtime, &tsb); if (0 == res) printf("%ld %ld\n", ts.tv_sec, ts.tv_nsec);