From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Peter Pastor <peter.pastor@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] detect mode switches to primary mode
Date: Sat, 06 Nov 2010 14:51:29 +0100 [thread overview]
Message-ID: <4CD55D61.7050208@domain.hid> (raw)
In-Reply-To: <AANLkTimpz6=DWjrKLRoG6O5XGotgQX6FTZR+U2b54awU@mail.gmail.com>
Peter Pastor wrote:
> Dear all,
>
> I am running several boarder line threads that are running in primary
> mode only when accessing some shared memory, otherwise I want them to
> run in secondary mode. I have used rt_task_set_mode to warn me upon
> switches to secondary modes, however, my question is, is there a similar
> way to detect mode switches to primary mode ?
>
> I have figured out a workaround using pthread_set_mode_np to force the
> thread to run in secondary mode (after shared memory access) and right
> before I force it back to primary mode do a printf and see whether I get
> a warning of switching into secondary mode (if so, then I know that the
> thread was running in primary mode, if not, then the thread was running
> in secondary mode.)
>
> Again, my question is, is there an elegant way to detect mode switches
> from secondary mode to primary mode ?
No there is not. The reason to detect switches from primary to secondary
mode is to debug issues of threads which should remain in primary mode,
nothing else. And pthread_set_mode_np(PTHREAD_PRIMARY) is deprecated.
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.
Next versions of Xenomai will get this borderline thread to switch
automatically to secondary mode when it releases the mutex (the patch
already exists).
--
Gilles.
next prev parent reply other threads:[~2010-11-06 13:51 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 [this message]
[not found] ` <AANLkTimhUUYDkHh6wJ_zL8dLJgCi+7F8kOXrA63LzTO9@domain.hid>
2010-11-06 15:34 ` Gilles Chanteperdrix
2010-11-06 16:08 ` Gilles Chanteperdrix
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=4CD55D61.7050208@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=peter.pastor@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.