All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Daniele Nicolodi <daniele@domain.hid>
Cc: Xenomai help <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] Which process synchronization primitive?
Date: Wed, 03 Mar 2010 18:10:20 +0100	[thread overview]
Message-ID: <4B8E97FC.5060502@domain.hid> (raw)
In-Reply-To: <4B8E9649.1060902@domain.hid>

Daniele Nicolodi wrote:
> Gilles Chanteperdrix wrote:
>> Daniele Nicolodi wrote:
>>> Gilles Chanteperdrix wrote:
>>>>> I think message queues can work well but I'm not sure they are the best
>>>>> choice when I do not have to communicate any message. Would be
>>>>> semaphores best suited to my needs?
>>>> You can use process-shared mutexes or semaphores.
>>> There is somewhere a comparison of the overhead of the different
>>> solutions? Do I need to do my own benchmarks? Is the API the only
>>> difference?
>> Mutexes have the lowest overhead, since they can be handled in
>> user-space starting with the 2.5 branch.
>>
>> Differences betwenn mutexes and semaphores are the same with Xenomai
>> than with any other known API: mutexes are binary semaphores with a
>> notion of ownership.
> 
> Thanks for the clarification. I have been reviewing the documentation
> and I think that what I need is a mutex with a condition variable shared
> between processes, or a semaphore.
> 
> The reason is that in my application I have processes that consume data
> produced by other processes, and I need to suspend the execution of the
> consumer until the producer has new data to handle.
> 
> Are condition variables also implemented in user space, so that their
> overhead is smaller compared to semaphores?

No. Condition variables imply scheduler decisions and context switches,
which can only occur in kernel-space, so, it would not really make sense
to implement them in user-space. The only case for which it would be
interesting is when you are signaling a condition while no thread is
waiting for it, but this case, is not really interesting in practice.

Please do not forget to C the mailing list.

-- 
Gilles Chanteperdrix, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com


      parent reply	other threads:[~2010-03-03 17:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02 13:13 [Xenomai-help] Which process synchronization primitive? Daniele Nicolodi
2010-03-02 13:21 ` Gilles Chanteperdrix
2010-03-02 13:41   ` Daniele Nicolodi
2010-03-02 18:05     ` Gilles Chanteperdrix
     [not found]       ` <4B8E9649.1060902@domain.hid>
2010-03-03 17:10         ` Gilles Chanteperdrix [this message]

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=4B8E97FC.5060502@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=daniele@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.