All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Peter Pastor Sampedro <pastorsa@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] detect mode switches to primary mode
Date: Sat, 06 Nov 2010 17:08:34 +0100	[thread overview]
Message-ID: <4CD57D82.4050007@domain.hid> (raw)
In-Reply-To: <AANLkTimhUUYDkHh6wJ_zL8dLJgCi+7F8kOXrA63LzTO9@domain.hid>

Peter Pastor Sampedro wrote:
> Hey Gilles,
> 
> Thanks for your prompt response !
> 
>> If you have a borderline thread sharing memory with a primary-mode only
>> thread, you are supposed to protect the accesses to the shared memory
>> with a mutex, then the borderline thread will automatically switch to
>> primary mode when it acquires the mutex. When it gets out of this
>> critical section and it calls a function which requires running in
>> secondary mode, then it will switch automatically to secondary mode.
> 
> That is exactly what I am doing. However, since I am linking my
> program against the posix skin, I may call some posix function in the
> non-real-time part of the boarder line thread which cause my thread to
> switch back to primary mode... which is exactly what I don't want it
> to do.
> 
> Anyways, thanks for letting me know that there is no clean way to see
> when/where mode switches from secondary to primary modes happen.
> 
> Thanks,
>  peter

Ok. Got it. But there must be some kind of misunderstanding: a high
priority thread running in secondary mode is not what you want, because
it makes it interruptible by non real-time interrupt, bottom halves,
tasklets, etc destroying its guaranteed latencies... But a null priority
thread running in primary mode is harmless. Since it has a null
priority, it will not prevent high priority thread from running.

Something else: if you want to avoid issues, the mutex protecting the
shared memory area shared between a high priority thread and the border
line thread should have priority inheritance enabled.

-- 
                                                                Gilles.


  parent reply	other threads:[~2010-11-06 16:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-06  2:26 [Xenomai-help] detect mode switches to primary mode Peter Pastor
2010-11-06 13:51 ` Gilles Chanteperdrix
     [not found]   ` <AANLkTimhUUYDkHh6wJ_zL8dLJgCi+7F8kOXrA63LzTO9@domain.hid>
2010-11-06 15:34     ` Gilles Chanteperdrix
2010-11-06 16:08     ` Gilles Chanteperdrix [this message]
2010-11-06 17:03   ` Peter Pastor
2010-11-06 18:20     ` Gilles Chanteperdrix
2010-11-06 19:43       ` Peter Pastor
2010-11-06 19:48         ` Gilles Chanteperdrix

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=4CD57D82.4050007@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=pastorsa@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.