All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Detecting switch to secondary mode
@ 2006-07-06 11:43 J. Niehaus
  2006-07-06 11:54 ` Jan Kiszka
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: J. Niehaus @ 2006-07-06 11:43 UTC (permalink / raw)
  To: xenomai

Hello,

I have written a xenomai application (posix-skin) with several tasks. All of them should normally use primary mode (SCHED_FIFO). While some are allowed to switch to secondary mode for stuff like I/O and memory allocation others must not switch due to hard realtime constraints. 

Is there a way to check if and how often a thread has switched to secondary mode and maybe even what system call caused the switch? While a test from within the program itself would be great some information from /proc/xenomai would also do.

Thanks,
	Jens


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Detecting switch to secondary mode
  2006-07-06 11:43 [Xenomai-help] Detecting switch to secondary mode J. Niehaus
@ 2006-07-06 11:54 ` Jan Kiszka
  2006-07-06 11:55 ` Philippe Gerum
  2006-07-06 12:04 ` Gilles Chanteperdrix
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2006-07-06 11:54 UTC (permalink / raw)
  To: J. Niehaus; +Cc: xenomai

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

J. Niehaus wrote:
> Hello,
> 
> I have written a xenomai application (posix-skin) with several tasks. All of them should normally use primary mode (SCHED_FIFO). While some are allowed to switch to secondary mode for stuff like I/O and memory allocation others must not switch due to hard realtime constraints. 
> 
> Is there a way to check if and how often a thread has switched to secondary mode and maybe even what system call caused the switch? While a test from within the program itself would be great some information from /proc/xenomai would also do.
> 

Yes, see this example:
http://www.rts.uni-hannover.de/xenomai/lxr/source/ksrc/skins/native/snippets/sigxcpu.c

We have the following code snippet in the signal handler of our RACK
framework:

void signal_handler(int sig)
{
[...]
    switch(sig)
    {
        case SIGXCPU:

            if (signal_flags & HANDLING_TERM) // ignore while
cleaning 		                                              // up
                return;

            printf("\n");
            printf("---=== SIGNAL HANDLER of %s ===---\n", classname);
            printf(" -> SIGXCPU (%02d)\n", sig);
            printf(" !!! WARNING unexpected switch to secondary mode "
                   "!!!\n");
            nentries = backtrace (array, 10);
            strings = backtrace_symbols (array, nentries);
            for (i = 0; i < nentries; i++)
            {
                printf ("  %s\n", strings[i]);
            }
            free (strings);
            printf("---=== END OF %s SIGNAL HANDLER ===---\n",
                   classname);
            return;
[...]

I.e. it does a back-trace to show what happened in user-space (debug
symbols are required). It's VERY useful when letting beginners hack
their first RT applications.

Jan


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Detecting switch to secondary mode
  2006-07-06 11:43 [Xenomai-help] Detecting switch to secondary mode J. Niehaus
  2006-07-06 11:54 ` Jan Kiszka
@ 2006-07-06 11:55 ` Philippe Gerum
  2006-07-06 12:04 ` Gilles Chanteperdrix
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Gerum @ 2006-07-06 11:55 UTC (permalink / raw)
  To: J. Niehaus; +Cc: xenomai

On Thu, 2006-07-06 at 13:43 +0200, J. Niehaus wrote:
> Hello,
> 
> I have written a xenomai application (posix-skin) with several tasks. All of them should normally use primary mode (SCHED_FIFO). While some are allowed to switch to secondary mode for stuff like I/O and memory allocation others must not switch due to hard realtime constraints. 
> 
> Is there a way to check if and how often a thread has switched to secondary mode and maybe even what system call caused the switch? While a test from within the program itself would be great some information from /proc/xenomai would also do.
> 

The MSW ("mode switch") column from /proc/xenomai/stats tells you how
many times any given thread switched to secondary mode; there is no
finer detail given though. Also, setting the PTHREAD_TRAPSW switch for a
thread using pthread_set_mode_np() makes Xenomai send this thread a
SIGXCPU signal upon switch from primary to secondary - it's a useful
debug tool when used along with GDB for instance.

> Thanks,
> 	Jens
> 
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help
-- 
Philippe.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Detecting switch to secondary mode
  2006-07-06 11:43 [Xenomai-help] Detecting switch to secondary mode J. Niehaus
  2006-07-06 11:54 ` Jan Kiszka
  2006-07-06 11:55 ` Philippe Gerum
@ 2006-07-06 12:04 ` Gilles Chanteperdrix
  2 siblings, 0 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2006-07-06 12:04 UTC (permalink / raw)
  To: J. Niehaus; +Cc: xenomai

J. Niehaus wrote:
 > Hello,
 > 
 > I have written a xenomai application (posix-skin) with several tasks. All of them should normally use primary mode (SCHED_FIFO). While some are allowed to switch to secondary mode for stuff like I/O and memory allocation others must not switch due to hard realtime constraints. 
 > 
 > Is there a way to check if and how often a thread has switched to secondary mode and maybe even what system call caused the switch? While a test from within the program itself would be great some information from /proc/xenomai would also do.

You may want to use pthread_set_mode_np:
http://www.xenomai.org/documentation/trunk/html/api/group__posix__thread.html#ga14

-- 


					    Gilles Chanteperdrix.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-06 12:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-06 11:43 [Xenomai-help] Detecting switch to secondary mode J. Niehaus
2006-07-06 11:54 ` Jan Kiszka
2006-07-06 11:55 ` Philippe Gerum
2006-07-06 12:04 ` Gilles Chanteperdrix

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.