All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: alex alex <duch.alexandre@gmail.com>
Cc: Xenomai <xenomai@xenomai.org>
Subject: Re: [Xenomai] [QUESTION] thread creation and hook function
Date: Mon, 15 Apr 2013 11:14:07 +0200	[thread overview]
Message-ID: <516BC4DF.3030302@xenomai.org> (raw)
In-Reply-To: <CAPpP=rNCBdcussSRzHN_Vpjj0afWZRGKRqPXxh7ps2-_GP7nBQ@mail.gmail.com>

On 04/15/2013 10:47 AM, alex alex wrote:
>> There are simple ways in the application itself, you do not need a
>> kernel module and a switch hook.
>
> The reason I use a switch hook is to retrieve informations about context
> switches to produce a Gantt chart of the sechuleur. But maybe hook
> functions are
> not suitable for this?


Yes, they are, but you should have introduced you mail topic mentioning 
your goal first. The ipipe tracer won't help you in this case.

You should be able to achieve this goal by interposing on the three 
hooks, possibly sending the collected data through a message pipe or 
XDDP socket to a userland app for post-processing.

Hints, for Xenomai 2.6 (-forge works differently):

- scheduler hooks are executed with core lock held, interrupts off: do 
not spend too much time there, or the timings would be affected too much.

- in the SWITCH hook, the following code would tell you whether you are 
looking at a regular linux thread, at a relaxed shadow thread, or at a 
Xenomai thread running in real-time mode, either in userland or kernel 
space:

struct xnthread *me, *t;

me = xnpod_current_thread(); /* this is fine, we are nklock-ed, irqs off */

if (xnthread_test_state(me, XNROOT)) {
	t = xnshadow_thread(current);
	if (t) {
		/* current is shadowed, t is Xenomai's mate, relaxed */
	} else {
		/* current is a regular linux task, no Xenomai shadow */
	}
} else if (xnthread_test_state(me, XNSHADOW)) {
	/* me is a user-space shadow in real-time mode. */
} else {
	/* me is a kernel-based Xenomai thread (always real-time). */
}

-- 
Philippe.


  reply	other threads:[~2013-04-15  9:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-13 16:58 [Xenomai] [QUESTION] thread creation and hook function alex alex
2013-04-13 17:41 ` Gilles Chanteperdrix
2013-04-13 18:20   ` alex alex
2013-04-13 20:55     ` Gilles Chanteperdrix
2013-04-13 22:41       ` alex alex
2013-04-13 23:05         ` Gilles Chanteperdrix
2013-04-13 23:07           ` Gilles Chanteperdrix
2013-04-13 23:37         ` Gilles Chanteperdrix
2013-04-15  8:47           ` alex alex
2013-04-15  9:14             ` Philippe Gerum [this message]
2013-04-15 10:25               ` alex alex
2013-04-15 12:36                 ` Philippe Gerum
2013-04-15 13:05                   ` Philippe Gerum
2013-04-15 13:08                     ` Philippe Gerum
2013-04-15 13:43                   ` alex alex
2013-04-15 13:48                     ` alex alex
2013-04-15 14:06                     ` Philippe Gerum
     [not found]                       ` <CAPpP=rMsqp5SOfq8_dNUOZ5UFugNa-YwsLyT5WT4d01_UTWRMA@mail.gmail.com>
2013-04-15 14:27                         ` Philippe Gerum
2013-04-15 19:45                           ` Gilles Chanteperdrix
2013-04-16  7:03                             ` Philippe Gerum
2013-04-15 19:43             ` 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=516BC4DF.3030302@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=duch.alexandre@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.