[so] test 6
cosminratiu at gmail.com
cosminratiu at gmail.com
Fri Nov 16 22:25:36 EET 2007
Pagina de manual la usleep:
4.3BSD, POSIX.1-2001. POSIX.1-2001 declares this function obsolete;
use nanosleep(2) instead.
On Nov 16, 2007 10:22 PM, Marius Nicolae <mariusn007 at gmail.com> wrote:
> On Nov 16, 2007 10:17 PM, Catalin Iacob <iacobcatalin at gmail.com> wrote:
> > On Friday 16 November 2007 22:03:34 Marius Nicolae wrote:
> > > Pai nici nu trebuie sa fac un sleep, am dormit deja x secunde cu
> > > sleep(ms/1000).
> >
> > Nu prea am urmarit thread-ul fiindca s-au intins foarte tare discutiile.
> >
> > Dar aici gresesti. Operatorul / in C/C++ iti face impartire intreaga.
> > Daca ms == 500 rezultatul 500/1000 == 0. Deci nu dormi deloc.
> > Similar, daca ms == 1900, 1900 / 1000 == 1 deci in loc de aproape 2
> secunde
> > dormi una singura.
> >
> > Nu stiu daca asta e problema ta (sau daca tu erai cel cu problema :D)
> dar
> > sleep(ms / 1000) suna gresit.
>
> Poate asa e mai clar:
>
> {
> sleep(ms/1000);
> usleep(ms%1000*1000);
> }
>
> Pentru ms==1900,
> prima instructiune este sleep(1) - doarme o secunda
> a doua instructiune este sleep(900000) - doarme 900 milisecunde
> --------------
> Total: 1900 ms
>
> >
> > Catalin
> >
> > _______________________________________________
> > so mailing list
> > so at cursuri.cs.pub.ro
> > http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so
> >
> _______________________________________________
> so mailing list
> so at cursuri.cs.pub.ro
> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cursuri.cs.pub.ro/pipermail/so/attachments/20071116/b364ac0b/attachment.htm
More information about the so
mailing list