All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Vincent Levesque <vleves@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Writing from user space direct to IO	Ports	without mode switches
Date: Fri, 20 Jul 2007 09:47:18 +0200	[thread overview]
Message-ID: <46A06886.5000703@domain.hid> (raw)
In-Reply-To: <469FD346.4060402@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 2729 bytes --]

Vincent Levesque wrote:
> Hi Philippe,
>> Excepts from your code:
>>   while(!end){
>>     //switch to primary mode
>>     ret = rt_task_set_mode(0, T_PRIMARY, NULL);
>>
>> Damnit. I knew this particular interface was going to be misused most of
>> the time. In short: do ____NOT_____ switch modes manually, this is
>> useless because Xenomai syscalls do it for you, and even sub-optimal
>> because the kernel knows better when it needs it and saves you a syscall
>> when required. The T_PRIMARY bit has been solely provided for internal
>> Xenomai purposes (some Xenomai libs have very special requirements in
>> very rare cases). rt_task_wait_period() will switch to primary mode if
>> needed, and always leave you in primary upon return.
>>   
> Indeed, I was also doing the same thing. From my understanding of the 
> docs, I assumed that manually setting a task to secondary mode was 
> allowed and could improve performance. Take for instance a task that 

Yes, it is allowed, but no, it doesn't improve performance.

> logs data coming from a RT_QUEUE to a file. Is there anything special 
> that should be done to minimize the impact of the frequent mode switches 
> in such a case?

As I once requested that mode switching feature, let my clarify its only
intended use case: RTDM devices may provide different support for
certain services (open/close/ioctl etc.) depending on the caller's
context. In order to let the caller control his context cleanly (ie.
without trickery to trigger automatic switches) in case there is support
for both modes for some device service, we introduced the explicit
switch interface. Really, this is the only scenario where switching
manually makes sense with Xenomai, and it is a corner case even under RTDM.

In all other cases, as Philippe explained, the Xenomai core will switch
for you transparently and efficiently. That even includes RTDM devices
which only support some service in one mode. E.g., rt_dev_read will
switch the caller to primary mode if the involved driver only provides a
read_rt handler and the caller was in secondary mode.

If you want to make your mode switches efficient, design your
applications in a way that you don't interleave Linux services with
blocking Xenomai services needlessly. Means, design the loop of your
borderline thread such that it only switches once to secondary mode and
back per cycle. But it sounds like your application (minus manual mode
switches) is already designed that way.

Hope that helped to clarify the situation. Now please let us know which
sentence(s) from the doc may have misled your understanding of the mode
switching feature. Maybe we have to rephrase them.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

  reply	other threads:[~2007-07-20  7:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-17 22:23 [Xenomai-help] Writing from user space direct to IO Ports without mode switches Renner Johannes
2007-07-18  6:47 ` Gilles Chanteperdrix
2007-07-18 10:19   ` [Xenomai-help] Writing from user space direct to IO Ports withoutmode switches Renner Johannes
2007-07-18  8:22 ` [Xenomai-help] Writing from user space direct to IO Ports without mode switches Philippe Gerum
2007-07-18 10:12   ` Renner Johannes
2007-07-18 10:47     ` Philippe Gerum
2007-07-19 21:10       ` Vincent Levesque
2007-07-20  7:47         ` Jan Kiszka [this message]
2007-07-20 19:28           ` Vincent Levesque

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=46A06886.5000703@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=vleves@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.