On Mon, 2010-04-19 at 12:28 +0200, Jan Kiszka wrote: > 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 <r...@xenomai.org> > CC: Alexis Berlemont <berlemont.h...@free.fr> > Signed-off-by: Jan Kiszka <jan.kis...@siemens.com> > --- > 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..d124157 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_root_p() || xnshadow_thread(current) != NULL); > +} > +
This patch still has fundamental flaw, the service would not work correctly and would actually return the wrong value, in case it is used deeply buried into some helper code, traversed by asynchronous Xenomai contexts. At the very least, you should avoid this by binding that service to a valid rtdm_dev_context, so that you know that it is called from a context that is correct in the first place, where a rtdm_dev_context reference is available. I.e. static inline int rtdm_rt_capable(struct rtdm_dev_context *context), and extract the information from that context structure. That would avoid a lot of headaches down the road to your user base. -- Philippe. _______________________________________________ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core