All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Giorgio Buffa <giorgiobuffa.work@gmail.com>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai] Device drivers and networking stack (RTnet) on Xenomai 3
Date: Mon, 29 Jun 2015 22:22:43 +0200	[thread overview]
Message-ID: <20150629202243.GE10993@hermes.click-hack.org> (raw)
In-Reply-To: <000a01d0b270$6c0e6b70$442b4250$@gmail.com>

On Mon, Jun 29, 2015 at 03:35:03PM +0200, Giorgio Buffa wrote:
> Hello list!
> I'm new to the Xenomai architecture, so I would like to receive a feedback
> regarding my (little) understanding on device drivers and the RTnet stack.
> 
> In dual-kernel configurations (both Xenomai 2.x and Xenomai 3.x Cobalt
> core), device drivers need to be ported to the RTDM model: it allows a
> Xenomai thread not to leave the primary mode when accessing these device
> drivers. This is good because a Xenomai thread in secondary mode is
> scheduled by the Linux scheduler, hence it can run only when there are no
> other runnable Xenomay thread in primary mode (even with a lower priority),
> nor other runnable Linux threads / Xenomai threads in secondary mode with
> higher priority.

Your comprehension of why threads must remain in primary mode is
flawed. Low priority threads having to let high priority threads run
before is always the case in a real-time system, and is not a
problem to be able to meet deadline, or if it is, it means you did
not choose your priorities correctly. The whole point of using a
real-time extension such as Xenomai dual-kernel or PREEMPT_RT is
that the Linux kernel is not deterministic, it does not provide any
guarantee in terms of scheduling latency. The time it takes for the
Linux kernel to schedule the highest priority task when an interrupt
happens is not bounded by design. So, that is the reason why a
Xenomai thread running in secondary mode (with a kernel that is not
patched with a combo of PREEMPT_RT and I-pipe that is) can not be
used in a real-time system, not the fact that higher priority
threads run before it.

> 
> Porting a Linux driver to the RTDM model basically means to replace any
> call to Linux services within the driver itself (e.g. to register the
> driver, the IRQ handlers, the open/close/ioctl handlers, ...) to the
> equivalent services provided by the RTDM API.
> 
> In single-kernel configurations (Xenomai 3.x Mercury core) there is only
> the Linux scheduler, hence there is no such distinction of
> primary/secondary mode. A device driver can be used as is (i.e. as it is
> provided by the stock Linux kernel), even without porting it to the RTDM
> model. By the way, it is also possible to use a RTDM-based device driver
> (in that case, RTDM API calls are translated into Linux service calls at
> compile time).

If you want to use Xenomai to implement a real-time system, using
Xenomai 3.x mercury core, the simplest way is to use a Linux kernel
patched with the PREEMPT_RT patch, but the PREEMPT_RT patch does not
automatically turn any driver in a driver that can be used in an
application trying to meet deadlines. The driver code needs to be
inspected. When porting a Linux driver to RTDM, this inspection was
already done, and RTDM does not provide services that can cause
trouble for real-time applications (for instance, mutexes without
priority inheritance). So, using an RTDM driver is a shortcut to
that. But the main reason to try and use RTDM drivers with Mercury
is for people that developed custom drivers for Xenomai 2.x, to be
able to use these drivers with mercury without rewriting them.

> 
> Are there some good "rules of thumb" when looking at a stock Linux driver
> to be used in a Xenomai application with the Mercury core
> underneath?

Yes, see above.

> 
> My last point is related to RTnet. I've seen that RTnet has been integrated
> into Xenomai 3 because some sort of API changes. Is RTnet needed in both
> dual-kernel and single-kernel configurations?

No, the reason to integrate RTnet in Xenomai 3, is because it makes
sense, and makes its maintenance easier. And no, RTnet is not
already usable with Mercury for the simple reason that RTDM has not
been ported to Xenomai 3 yet.

-- 
					    Gilles.
https://click-hack.org


  reply	other threads:[~2015-06-29 20:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-29 13:35 [Xenomai] Device drivers and networking stack (RTnet) on Xenomai 3 Giorgio Buffa
2015-06-29 20:22 ` Gilles Chanteperdrix [this message]
2015-06-30  8:04   ` [Xenomai] R: " Giorgio Buffa
2015-06-30  9:10     ` Gilles Chanteperdrix
2015-06-30  9:56       ` 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=20150629202243.GE10993@hermes.click-hack.org \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=giorgiobuffa.work@gmail.com \
    --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.