Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: usleep question.



On Sunday 07 April 2002 14:42, Carsten Koch wrote:
> Andreas Schultz wrote:
> ...
>
> > so, we are using nanosleep ;-)
>
> Good.
> Does that mean the suggestion in the man page is obsolete?

don't know, you should ask the glibc developers on that, there might be very 
good reasons not to use it ....

> > The selection of 1ms is arbritraty and could probably also replace by
> > sched_yield().
>
> usleep(1) does not request 1 ms, but 1/1000 ms!
> 1ms would be usleep(1000).

right, but its Sunday, so i hope you forgive me ;-)

> > asmlinkage long sys_nanosleep(struct timespec *rqtp, struct timespec
> > *rmtp) {
> >     .....
> >                 /*
> >                  * Short delay requests up to 2 ms will be handled with
> >                  * high precision by a busy wait for all real-time
> > processes. *
> >
> > This explains the lookup's when running under real-time scheduling. The
> > scheduler will not allow other process to run, therefore completly
> > blocking out all other processes.
>
> That also suggests that it would be safer to use
> usleep(10000) instead of usleep(1), doesn't it?

to me, it suggest not to use usleep() at all. Waiting for some other task to 
complete something should be done through the mechanisms designed for that 
(mutex, condition variable, semaphore).

sorry for pointing it out again, there is a patch to remove most of the 
usleep() stuff at:
http://www.cs.uni-magdeburg.de/~aschultz/dvd/vdr-1.0.0pre3-sync.diff.bz2
The patch leaves some usleep's in the transfer and recoding stuff, but i think 
they will not used anymore.

Andreas



Home | Main Index | Thread Index