From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: "Stoidner, Christoph" <c.stoidner@arvero.de>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] Sleeping function called from invalid context
Date: Tue, 9 Dec 2014 21:55:08 +0100 [thread overview]
Message-ID: <20141209205508.GP30777@hermes.click-hack.org> (raw)
In-Reply-To: <61165410f8a5408a8b2ff2fac74fd503@EX132MBOX1A.de2.local>
On Tue, Dec 09, 2014 at 08:47:54PM +0000, Stoidner, Christoph wrote:
> >> >>
> >> >> >> #ifndef DEFINE_SEMAPHORE
> >> >> >> /* Legacy DECLARE_MUTEX vanished in 2.6.37 */
> >> >> >> #define DEFINE_BINARY_SEMAPHORE(sem) DECLARE_MUTEX(sem)
> >> >> >> -#elif defined(CONFIG_PREEMPT_RT)
> >> >> >> -#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1)
> >> >> >> +#elif defined(CONFIG_PREEMPT_RT_FULL)
> >> >> >> +#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
> >> >> >> #else
> >> >> >> #define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
> >> >> >> #endif
> >> >>
> >> >> > Why that change? I mean in 2.6.37, the define was CONFIG_PREEMPT_RT
> >> >> > anwyay.
> >> >>
> >> >> If DEFINE_SEMAPHORE is not defined we are below 2.6.37. So for 2.6.37 and above CONFIG_PREEMPT_RT was checked.
> >>
> >> > Well, are not we in the "elif" case of the #ifndef DEFINE_SEMAPHORE,
> >> > so DEFINE_SEMAPHORE is defined, or am I missing something ?
> >>
> >> Let me explain that more in detail:
> >>
> >> DEFINE_SEMAPHORE is defined for linux >= 2.6.37
> >>
> >> So for linux 2.6.37 we are in
> >>
> >> #elif defined(CONFIG_PREEMPT_RT)
> >>
> >> Also in linux 3.0.0 we are in that elif. Since in 3.0.0 and above CONFIG_PREEMPT_RT
> >> was changed to CONFIG_PREEMPT_RT_FULL, so we have to use the latter one instead.
>
> > Ok, but please the two ifdefs then, one for PREEMPT_RT and the other
> > for PREEMT_RT_FULL. This will avoid breaking is someone decides to
> > change the header and moves the chunks around.
>
> Sorry, maybe I am a little bit confused but I do not understand
> what you mean. There is only one ifdef using CONFIG_PREEMPT_RT.
> This is required for compatibility to lower kernel versions to
> introduce newer CONFIG_PREEMPT_RT_FULL. All other code parts are
> using CONFIG_PREEMPT_RT_FULL afterwards.
This is what I asked in Xenomai code. But in wrappers.h, I would
prefer the code to not depend on the order of the definitions.
Currently, you have, at the beginning of the file
#if whatever
#ifdef CONFIG_PREEMPT_RT
#define CONFIG_PREEMPT_RT_FULL
#endif
#endif
And later:
#ifdef CONFIG_PREEMPT_RT_FULL
This works because if we are in the PREEMPT_RT case, the define at
the top of the file will get PREEMT_RT_FULL defined.
Now, if someone decides to move the ifdef from the top of the file
to the bottom of the file. The binary semaphore defines breaks.
Whereas if at the bottom of the file, you use:
#ifdef CONFIG_PREEMPT_RT
foo
#elif define CONFIG_PREEMPT_RT_FULL
foo
You no longer have this issue.
Beware of these ifdefs, breakage is easy and may long stay
unnoticed.
--
Gilles.
next prev parent reply other threads:[~2014-12-09 20:55 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-06 14:19 [Xenomai] Sleeping function called from invalid context Stoidner, Christoph
2014-12-06 14:25 ` Gilles Chanteperdrix
2014-12-06 15:11 ` Stoidner, Christoph
2014-12-07 12:32 ` Stoidner, Christoph
2014-12-07 12:40 ` Gilles Chanteperdrix
2014-12-07 13:50 ` Stoidner, Christoph
2014-12-07 13:52 ` Gilles Chanteperdrix
2014-12-07 15:05 ` Stoidner, Christoph
2014-12-09 20:06 ` Stoidner, Christoph
2014-12-09 20:08 ` Gilles Chanteperdrix
2014-12-09 20:18 ` Stoidner, Christoph
2014-12-09 20:24 ` Gilles Chanteperdrix
2014-12-09 20:34 ` Stoidner, Christoph
2014-12-09 20:37 ` Gilles Chanteperdrix
2014-12-09 20:47 ` Stoidner, Christoph
2014-12-09 20:55 ` Gilles Chanteperdrix [this message]
2014-12-09 20:49 ` Stoidner, Christoph
2014-12-09 20:59 ` Gilles Chanteperdrix
2014-12-10 16:23 ` Stoidner, Christoph
2014-12-10 16:26 ` Gilles Chanteperdrix
2014-12-10 18:23 ` Stoidner, Christoph
2014-12-10 18:41 ` Gilles Chanteperdrix
-- strict thread matches above, loose matches on Subject: below --
2014-12-10 18:58 Stoidner, Christoph
2014-12-10 19:01 ` Gilles Chanteperdrix
2014-12-11 10:00 ` Stoidner, Christoph
2014-12-11 10:05 ` Gilles Chanteperdrix
2014-12-11 10:18 ` Stoidner, Christoph
2014-12-11 10:22 ` Gilles Chanteperdrix
2014-12-11 10:29 ` Stoidner, Christoph
2014-12-11 10:47 ` Gilles Chanteperdrix
2014-12-11 11:17 ` Stoidner, Christoph
2014-12-11 14:47 ` Gilles Chanteperdrix
2014-12-11 15:47 ` Stoidner, Christoph
2014-12-11 16:06 ` Gilles Chanteperdrix
2014-12-11 16:31 ` Stoidner, Christoph
2014-12-11 16:38 ` Gilles Chanteperdrix
2014-12-11 19:23 ` Stoidner, Christoph
2014-12-12 16:42 ` Stoidner, Christoph
2014-12-15 11:42 ` Stoidner, Christoph
2014-12-15 13:23 ` Gilles Chanteperdrix
2014-12-15 13:29 ` Stoidner, Christoph
2014-12-15 14:20 ` Gilles Chanteperdrix
2014-12-15 15:11 ` Stoidner, Christoph
2014-12-15 15:19 ` Gilles Chanteperdrix
2014-12-17 12:24 ` Stoidner, Christoph
2014-12-17 12:38 ` Gilles Chanteperdrix
2014-12-17 13:22 ` Gilles Chanteperdrix
2014-12-17 15:46 ` Gilles Chanteperdrix
2014-12-17 22:40 ` Stoidner, Christoph
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=20141209205508.GP30777@hermes.click-hack.org \
--to=gilles.chanteperdrix@xenomai.org \
--cc=c.stoidner@arvero.de \
--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.