[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: pthread_delay_np



Of course, but I want only a specified thread to wait for that specified
time. Doesn't sleep etc relate to processes rather than threads? This
seemingly simple requirement seems quite difficult to achive with
pthreads. I have been thinking of SIGALRM; but too gets messy since
signal handlers will be shared and all threads have different masks. And
I have two threads which need to (parallely and independently) sleep for
different time intervals. ANy neat way of doing this? 

Thanks,
Vinay.

Arun Sharma wrote:
> 
> > Arun,
> >
> > Could you then tell me how to wait for a specified milli/micro/nano secs
> > within a thread? I need that for some network simulation. Does
> > pthread_cond_timedwait() sound like a good idea for that (I could create
> > a condition that never occurs)? That looks very ugly to me. Is there a
> > portable way to wait for an approximate time within a thread?
> >
> 
> Look for sleep, usleep and nanosleep(2).
> 
>     -Arun