Forum Discussion
Altera_Forum
Honored Contributor
20 years agousleep and select timeout
I wrote some test programs to test out the usleep and select timeout functions. The NIOS II processor seems to have a minimum resolution of 10 ms. usleep also has a tendency to double the sleep tim...
Altera_Forum
Honored Contributor
20 years agoI was up till midnight trying to find a solution... at least to the delay hanging up a loop.
Here is what I found: while(1) { prinft("."); usleep(100000); } The above code seems to hang on NIOS II processor and Intel based processor linux. However after having some patience it bursts output after about a minute of waiting. So... what is the difference between this and the delay tests I made in the original post....? Here is a reduced version of the delay test... while(1) { start timer; printf("something\n"); sleep; stop timer; printf("timing difference\n"); } So... the big difference is the \n (carriage return line feed). LINUX seems to buffer the console output until it runs out of buffer or it finds a carriage return line feed when used IN CONJUNCTION WITH USLEEP or any type of blocking delay. Why does it do this and how do I tell LINUX to stop doing that. Thanks.... Also if anyone knows how to increase the resolution of the usleep or why it sleeps for 10 more milliseconds that you tell it that would be great too...