All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: Jan Kiszka <jan.kiszka@domain.hid>,
	xenomai-core <xenomai@xenomai.org>,
	Alexis Berlemont <berlemont.hauw@domain.hid>
Subject: Re: [Xenomai-core] [PATCH v3 02/24] RTDM: Add rtdm_rt_capable() service
Date: Sun, 18 Apr 2010 15:30:09 +0200	[thread overview]
Message-ID: <1271597409.16659.37.camel@domain.hid> (raw)
In-Reply-To: <1271597170.16659.34.camel@domain.hid>

On Sun, 2010-04-18 at 15:26 +0200, Philippe Gerum wrote:
> On Sun, 2010-04-18 at 15:12 +0200, Jan Kiszka wrote:
> > From: Jan Kiszka <jan.kiszka@domain.hid>
> > 
> > This adds rtdm_rt_capable(), a function that can be used by drivers to
> > detect callers that could issue a service request also from the
> > (typically preferred) real-time context. If that is the case, the driver
> > can trigger a restart of the request if the current context is not
> > real-time.
> > 
> > CC: Philippe Gerum <rpm@xenomai.org>
> > CC: Alexis Berlemont <berlemont.hauw@domain.hid>
> > Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
> > ---
> >  include/rtdm/rtdm_driver.h |    6 ++++++
> >  ksrc/skins/rtdm/drvlib.c   |   25 +++++++++++++++++++++++++
> >  2 files changed, 31 insertions(+), 0 deletions(-)
> > 
> > diff --git a/include/rtdm/rtdm_driver.h b/include/rtdm/rtdm_driver.h
> > index 0fc1496..45be404 100644
> > --- a/include/rtdm/rtdm_driver.h
> > +++ b/include/rtdm/rtdm_driver.h
> > @@ -1296,6 +1296,12 @@ static inline int rtdm_in_rt_context(void)
> >  {
> >  	return (rthal_current_domain != rthal_root_domain);
> >  }
> > +
> > +static inline int rtdm_rt_capable(void)
> > +{
> > +	return xnpod_shadow_p();
> > +}
> > +
> 
> This won't do what your comment states; xnpod_shadow_p() would always
> return false on behalf of a relaxed shadow, since it tests the status
> bits of the current Xenomai thread, which has to be the root one in that
> case. xnpod_shadow_p is to be used in primary context only, to
> distinguish between kernel-based and userland Xenomai callers. 
> 
> What you want is probably something like:
> 
> static inline int rtdm_rt_capable(void)
> {
> 	return xnshadow_thread(current) != NULL;
> }

Btw, the predicate as you defined it would not work over kernel-based
Xenomai threads. rtdm_rt_capable() is ambiguous here.

> 
> 
> >  #endif /* !DOXYGEN_CPP */
> >  
> >  int rtdm_exec_in_rt(struct rtdm_dev_context *context,
> > diff --git a/ksrc/skins/rtdm/drvlib.c b/ksrc/skins/rtdm/drvlib.c
> > index 3b04493..6e26501 100644
> > --- a/ksrc/skins/rtdm/drvlib.c
> > +++ b/ksrc/skins/rtdm/drvlib.c
> > @@ -2341,6 +2341,31 @@ int rtdm_strncpy_from_user(rtdm_user_info_t *user_info, char *dst,
> >   */
> >  int rtdm_in_rt_context(void);
> >  
> > +/**
> > + * Test if the caller is capable of running in real-time context
> > + *
> > + * @return Non-zero is returned if the caller is able to execute in real-time
> > + * context (independent of its current execution mode), 0 otherwise.
> > + *
> > + * @note This function can be used by drivers that provide different
> > + * implementations for the same service depending on the execution mode of
> > + * the caller. If a caller requests such a service in non-real-time context
> > + * but is capable of running in real-time as well, it might be appropriate
> > + * for the driver to reject the request via -ENOSYS so that RTDM can switch
> > + * the caller and restart the request in real-time context.
> > + *
> > + * Environments:
> > + *
> > + * This service can be called from:
> > + *
> > + * - Kernel module initialization/cleanup code
> > + * - Kernel-based task
> > + * - User-space task (RT, non-RT)
> > + *
> > + * Rescheduling: never.
> > + */
> > +int rtdm_rt_capable(void);
> > +
> >  #endif /* DOXYGEN_CPP */
> >  
> >  /** @} Utility Services */
> 
> 


-- 
Philippe.




  reply	other threads:[~2010-04-18 13:30 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-18 13:12 [Xenomai-core] [PATCH v3 00/24] [git pull v3] RTDM fixes and reworks Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 01/24] RTDM: Fix potential NULL pointer dereference Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 02/24] RTDM: Add rtdm_rt_capable() service Jan Kiszka
2010-04-18 13:26   ` Philippe Gerum
2010-04-18 13:30     ` Philippe Gerum [this message]
2010-04-18 13:40       ` Jan Kiszka
2010-04-18 21:09         ` Philippe Gerum
2010-04-19  7:31           ` Jan Kiszka
2010-04-19  7:37             ` Philippe Gerum
2010-04-19  7:39               ` Philippe Gerum
2010-04-18 13:30     ` Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 03/24] RTDM: Bump API version and document changes Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 04/24] Revert "rtdm: tag syscalls as conforming" Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 05/24] RTDM: Deprecate open_rt, socket_rt, and close_rt Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 06/24] RTIPC: Fix memory leak on failing socket creation Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 07/24] RTIPC: Drop support for RT socket creation/deletion Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 08/24] RTCAN: Drop support for socket creation/deletion in real-time Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 09/24] 16550A: Drop support for device opening/closing " Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 10/24] Analogy: Drop support for " Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 11/24] RTDM: Instrument rtdm_context_lock/unlock to detect misuses Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 12/24] RTDM: Add rtdm_context_put() Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 13/24] Fix historic msleep wrapping Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 14/24] irqbench: Fix x86-64 build Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 15/24] irqbench: Refactor user space helpers Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 16/24] irqbench: Auto-detect bases of port address and IRQ values Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 17/24] rttest: Resolved test device conflicts via separate name spaces Jan Kiszka
2010-04-18 17:13   ` Gilles Chanteperdrix
2010-04-18 17:28     ` Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 18/24] testing: Clean up Kconfig rules Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 19/24] RTIPC: Drop unused wrapper around close_lock_count Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 20/24] RTDM: Document device close procedure Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 21/24] Add list_first_entry wrapper for older kernels Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 22/24] Add legacy kernel support for delayed_work Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 23/24] RTDM: Early fd release with poll-free context reference tracking Jan Kiszka
2010-04-18 17:18   ` Gilles Chanteperdrix
2010-04-18 17:28     ` Jan Kiszka
2010-04-18 13:12 ` [Xenomai-core] [PATCH v3 24/24] RTDM: Add basic unit test Jan Kiszka

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=1271597409.16659.37.camel@domain.hid \
    --to=rpm@xenomai.org \
    --cc=berlemont.hauw@domain.hid \
    --cc=jan.kiszka@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.