Nico and Brett,

I don't think usleep can solve his problem.

OP wants the loop to create/run for 10ms.
If you put  a usleep it will simply sleep there and the iteration will
start again after 10 ms.

Best,
-Saswat


On Thu, 2006-12-21 at 19:52 +0000, Nico Heinze wrote:
> --- In [email protected], "Brett W. McCoy" <[EMAIL PROTECTED]>
> wrote:
> >
> > On 12/20/06, 1512 1521 <[EMAIL PROTECTED]> wrote:
> > >
> > > I need to create a for loop for 10ms, how can I calculate 10 ms?
> > >
> > > for (i=0,i<??,i++) =>10ms
> > > ....
> > > ...
> > > ...
> > > for (i=0,i<??,i++) =>10ms
> > >
> > 
> > You can't. You should use timer functions for this, like the
> > POSIX functions sleep, alarm, etc. If you are using Win32,
> > there are equivalent functions, I am sure (I don't know what
> > they are), refer to the documentation for your compiler
> > 
> > -- Brett
> 
> On POSIX conformant systems, there's a system call named "usleep()"
> which takes a number of microseconds as its parameter and has the
> process sleep (at least) the given amount of time.
> 
> Unfortunately Windows doesn't offer this function; here you will have
> to set up a timer which will notify your application via the usual
> message queue as soon as the timer has expired.
> 
> Regards,
> Nico
> 
> 
> 
> 
> 
>  

Reply via email to