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