All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Alexis Berlemont <berlemont.hauw@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Analogy cmd_write example explanation
Date: Sat, 13 Mar 2010 10:28:43 +0100	[thread overview]
Message-ID: <1268472523.27899.135.camel@domain.hid> (raw)
In-Reply-To: <4B9AD0DE.4020103@domain.hid>

On Sat, 2010-03-13 at 00:40 +0100, Alexis Berlemont wrote:
> Hi,
> 
> Sorry for answering so late. I took a few days off far from any internet
> connection.
> 
> It seems you sent many mails related with Analogy. Many thanks for your
> interest. I have not read all of them yet. However, I am beginning by
> this one (which seems unanswered). The answer is quick and easy :)
> 
> Daniele Nicolodi wrote:
> > Hello. I'm looking into the analogy cmd_write example.
> > 
> > I'm not sure I understand the reason for the rt_task_set_mode() function
> > call into the data acquisition loop (lines 413 or 464 in the code
> > shipped with xenomai 2.5.1).
> > 
> > I do not understand why we have to set the primary mode at every
> > iteration, when we set it before for the task (line 380).
> > 
> > Is it because the dump_function() uses system calls that can make the
> > task to switch to secondary mode, or there is a deeper reason I'm missing?
> > 
> You are right. The dumping routine triggers a switch to secondary mode.
> That is why, the program switches back to primary mode after.

This is wrong. The Xenomai core will switch your real-time thread to
primary mode automatically when running a4l_insn* calls that end up
invoking rt_dev_ioctl(), since you did declare a real-time entry point
for this one.

Let's summarize the whole point of forcing primary mode through
rt_task_set_mode(): it's bad, it's wrong, it's counter-productive
CPU-wise, it usually reveals a design issue in the calling code in most
cases.

The only application-level use case where switching to primary mode
eagerly this way might make sense, is when the code first switches to
secondary, then runs an awful lot of CPU-intensive code without issuing
any syscall, one might want to keep un-preempted from Linux IRQs. In
such a case, the question which arises immediately is: why the hell does
one ever tolerate switching to secondary mode initially, if strict
timely behavior is wanted later on? 

That crap is a freaking mistake of mine, when I exported such
anti-feature via the native API mindlessly, to provide a work-around for
rare situations some internal Xenomai code might benefit from. I should
have provided an internal syscall instead, to hide this monster deep
into the abyssal zone it should never have left.

In short: DO NOT USE THIS.

> 
> Almost all the Analogy programs (cmd_read, cmd_write, insn_read,
> insn_write, insn_bits) are just demonstration examples. That is why the
> code is so linear, lengthy and repetitive. Furthermore, the code was not
> meant to be efficient. I just wanted to test the RT and NRT entries.
> 
> By the way, I started to improve them. One change (which is still
> missing) is the use of rtdk.
> 
> > Thanks. Cheers,
> 
> Alexis.
> 
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help


-- 
Philippe.




  reply	other threads:[~2010-03-13  9:28 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-10 15:26 [Xenomai-help] Analogy cmd_write example explanation Daniele Nicolodi
2010-03-12 23:40 ` Alexis Berlemont
2010-03-13  9:28   ` Philippe Gerum [this message]
2010-03-13 16:13     ` Alexis Berlemont
2010-03-13 16:33       ` Philippe Gerum
2010-03-13 23:34         ` Alexis Berlemont
2010-03-14 16:34           ` Philippe Gerum
2010-03-15  7:50             ` Jan Kiszka
2010-03-15 23:30               ` Alexis Berlemont
2010-03-16  8:59                 ` Jan Kiszka
2010-03-18 20:35                 ` Philippe Gerum
2010-03-18 21:14                   ` Alexis Berlemont
2010-03-18 21:39                     ` Philippe Gerum
2010-04-01 19:47             ` Gilles Chanteperdrix
2010-04-01 21:13               ` Jan Kiszka
2010-04-01 21:22                 ` Philippe Gerum
2010-04-01 21:26                   ` Jan Kiszka
2010-04-01 21:31                     ` Philippe Gerum
2010-04-01 21:36                       ` Jan Kiszka
2010-04-01 21:48                         ` Philippe Gerum
2010-04-01 21:54                           ` Jan Kiszka
2010-04-01 22:00                             ` Philippe Gerum
2010-04-01 22:07                               ` Jan Kiszka
2010-04-01 22:53                                 ` Gilles Chanteperdrix
2010-04-01 22:58                                   ` Jan Kiszka
2010-04-01 23:08                                     ` Gilles Chanteperdrix
2010-04-02  0:04                                       ` Jan Kiszka
2010-04-02 10:39                                         ` [Xenomai-core] " Gilles Chanteperdrix
2010-04-02 11:11                                           ` Jan Kiszka
2010-04-02 11:14                                             ` Gilles Chanteperdrix
2010-04-02 11:28                                               ` Jan Kiszka
2010-04-13 20:41                                                 ` Philippe Gerum
2010-04-13 23:05                                                   ` Jan Kiszka
2010-04-14  7:22                                                     ` Philippe Gerum
2010-04-14  7:37                                                       ` Jan Kiszka
2010-04-14  7:51                                                         ` Jan Kiszka
2010-04-14  9:04                                                         ` Philippe Gerum
2010-04-14 17:13                                                           ` Gilles Chanteperdrix
2010-04-14 19:35                                                           ` Jan Kiszka
2010-04-14  8:24                                                   ` Gilles Chanteperdrix
2010-04-01 21:24               ` Philippe Gerum
2010-04-01 21:39                 ` Jan Kiszka
2010-04-01 21:59                   ` Philippe Gerum
2010-04-01 22:12                     ` Jan Kiszka
2010-04-01 21:50               ` Jan Kiszka
2010-04-01 21:54                 ` 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=1268472523.27899.135.camel@domain.hid \
    --to=rpm@xenomai.org \
    --cc=berlemont.hauw@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.