All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Terry Fryar <terry.fryar@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Use of condition vars
Date: Fri, 30 Dec 2011 00:56:26 +0100	[thread overview]
Message-ID: <4EFCFE2A.8070505@domain.hid> (raw)
In-Reply-To: <32A50F80EA7447F2B43C6A65BED53790@domain.hid>

On 12/29/2011 09:39 PM, Terry Fryar wrote:
> Using Xenomai 2.6.0, I have a question regarding the use of condition
> variables.  I think I understand why the mutex is required, but how to use
> it is a bit of a mystery?
>  
> - To call "rt_cond_signal()", do you have to have the mutex acquired??
>  
> - I assume to call "rt_cond_wait()", you are required to have the mutex
> acquired, yes??

You have to hold the mutex both for rt_cond_signal() and rt_cond_wait().
The following exercpt from linuxthreads man pages explains it:

A condition variable must always be associated with a mutex,  to  avoid
the race condition where a thread prepares to wait on a condition vari‐
able and another thread signals the condition  just  before  the  first
thread actually waits on it.

-- 
                                                                Gilles.



  reply	other threads:[~2011-12-29 23:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-29 20:39 [Xenomai-help] Use of condition vars Terry Fryar
2011-12-29 23:56 ` Gilles Chanteperdrix [this message]
2012-01-02 14:03   ` Terry Fryar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EFCFE2A.8070505@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=terry.fryar@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.