tech-userlevel archive

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

Re: Q about pthread condition variable usage - mixing interlocks



On Thu 08 Apr 2021 at 11:42:15 -0700, Phil Nelson wrote:
> It appears to me that the code is expecting only one mutex and that it is
> held at cond_wait time and thus should have no problem re-locking the mutex.

The second item ("it is held at cond_wait time") is implied (but not
really spelled out) in pthread_cond(3):

     The pthread_cond_wait() function atomically blocks the current thread
     waiting on the condition variable specified by cond, and unlocks the
                                                              ^^^^^^^^^^^
     mutex specified by mutex.  The pthread_cond_timedwait() function behaves
     ^^^^^^^^^^^^^^^^^^^^^^^^

-Olaf.
-- 
___ Q: "What's an anagram of Banach-Tarski?"  -- Olaf "Rhialto" Seibert
\X/ A: "Banach-Tarski Banach-Tarski."         -- rhialto at falu dot nl

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index