Re: pthread and nanosleep



DUDULE wrote:
I do not understand why. It seems like nanosleep suspends all the threads
(not only the calling one).

You can consider using sched_yield instead of nanosleep:

1,3d0
< struct timespec duree_nanosleep, duree_out;
< duree_nanosleep.tv_sec=0;
< duree_nanosleep.tv_nsec=10000000; //10 ms
13,14c10
< // if I comment out this line, the program is much faster.
< nanosleep(&duree_nanosleep,&duree_out);
---
sched_yield();

But a tricky code remains a tricky one.

Best Regards,
Szabolcs
.