Pagina de manual la usleep:<br><br> 4.3BSD, POSIX.1-2001. POSIX.1-2001 declares this function obsolete; use nanosleep(2) instead.<br><br><br><div class="gmail_quote">On Nov 16, 2007 10:22 PM, Marius Nicolae <<a href="mailto:mariusn007@gmail.com">
mariusn007@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Nov 16, 2007 10:17 PM, Catalin Iacob <
<a href="mailto:iacobcatalin@gmail.com">iacobcatalin@gmail.com</a>> wrote:<br>> On Friday 16 November 2007 22:03:34 Marius Nicolae wrote:<br>> > Pai nici nu trebuie sa fac un sleep, am dormit deja x secunde cu
<br>> > sleep(ms/1000).<br>><br>> Nu prea am urmarit thread-ul fiindca s-au intins foarte tare discutiile.<br>><br>> Dar aici gresesti. Operatorul / in C/C++ iti face impartire intreaga.<br>> Daca ms == 500 rezultatul 500/1000 == 0. Deci nu dormi deloc.
<br>> Similar, daca ms == 1900, 1900 / 1000 == 1 deci in loc de aproape 2 secunde<br>> dormi una singura.<br>><br>> Nu stiu daca asta e problema ta (sau daca tu erai cel cu problema :D) dar<br>> sleep(ms / 1000) suna gresit.
<br><br></div>Poate asa e mai clar:<br><br>{<br> sleep(ms/1000);<br> usleep(ms%1000*1000);<br>}<br><br>Pentru ms==1900,<br>prima instructiune este sleep(1) - doarme o secunda<br>a doua instructiune este sleep(900000) - doarme 900 milisecunde
<br>--------------<br>Total: 1900 ms<br><div><div></div><div class="Wj3C7c"><br>><br>> Catalin<br>><br>> _______________________________________________<br>> so mailing list<br>> <a href="mailto:so@cursuri.cs.pub.ro">
so@cursuri.cs.pub.ro</a><br>> <a href="http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so" target="_blank">http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so</a><br>><br>_______________________________________________
<br>so mailing list<br><a href="mailto:so@cursuri.cs.pub.ro">so@cursuri.cs.pub.ro</a><br><a href="http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so" target="_blank">http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so</a>
<br></div></div></blockquote></div><br>