Mailing List archive

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

[vdr] Re: vdr 1.3.18 cCondWait::SleepMs (was: vdr 1.3.18 with subtitles and ttxtsubs plugin)




> -----Original Message-----
> From: vdr-bounce@linuxtv.org [mailto:vdr-bounce@linuxtv.org] On Behalf Of
> Rainer Zocholl
> Sent: den 10 januari 2005 17:03
> To: vdr@linuxtv.org
> Subject: [vdr] Re: vdr 1.3.18 cCondWait::SleepMs (was: vdr 1.3.18 with
> subtitles and ttxtsubs plugin)
> 
> Hello
> 
> 
> Wouldn't it be use full if (some kind of) cCondWait::SleepMs returns
> the result of cCondWait::Wait so the calling thread might be
> able to do some houskeeping in the case of an termination signal
> and does not continue to call the SleepMs?
> 
> Especially as "signaled" is reset which every call to SleepMs
> and termination of Wait.
> 
> Else i don't see what's the sense of "signaled".
> Isn't redundant if it is cleared outside the "constructor"?
> 
> 
> AFAIK pthread_cond_timedwait unlocks the mutex.
> Only on timeout it becomes relocked, not on "condition".
> Why is it unlocked a second time at the end of the function
> regardless of the state of "signaled" ?
> 

Hmm, I do thing that you are wrong here, take a look at a more descriptive
man page fore pthread_cond_wait (they shall both impellent the same
standard):

http://docs.hp.com/en/B2355-90695/pthread_cond_wait.3T.html

The interesting part:
    When the condition is signaled or the timed wait expires, the caller is
    unblocked and will reacquire mutex before returning. Whether these
    functions succeed or fail, mutex will always be reacquired before
    returning to the caller.


I have been trying to find a better description of the 2 ms limit in
nanosleep other then the man-page for nanosleep under BUGS in Fedora Core 2.


    As some applications require much more precise pauses (e.g., in  order
    to  control  some  time-critical hardware), nanosleep is also capable of
    short high-precision pauses. If the process is scheduled under a
    real-time policy like SCHED_FIFO or SCHED_RR, then pauses of up to 2 ms
    will be performed as busy waits with microsecond precision.

I have been trying to understand the implementation of nanosleep, but gave
up when I couldn't even find the code for it in glibc ;).

/Mattias

> 
> BTW:
> http://www2.yo-linux.com/cgi-
> bin/man.cgi?section=all&topic=pthread_cond_timedwait
> 
> ASYNC-SIGNAL SAFETY
> 
>        The  condition  functions  are not async-signal safe,
>        and should not be called from a signal handler.
>        In particular, calling
>          pthread_cond_signal or
>          pthread_cond_broadcast
>        from a signal handler may deadlock the calling thread.
> 
> 
> Where is cCondWait::Signal called from?
> 
> 
> 
> 
> Rainer
> 







Home | Main Index | Thread Index