accessing context switch counter from rttask
Hi!
I searched for a while and found this snippet
RT_TASK *rt = rt_task_self();
int x = rt->thread_base.stat.csw;
should give the number of context switches, but:RT_TASK in non-kernel mode is only RT_TASK_PLACEHOLDER so i have no access to thread_base!
Is there an official way to get this info (w/o opening "/proc/xenomai/...")?
TIA,
Peter
Quoted 7 lines · Gsellmann Peter
Hi!
I searched for a while and found this snippet
RT_TASK*rt =rt_task_self();
int x =rt->thread_base.stat.csw;
Quoted 7 lines
should give the number of context switches, but:
RT_TASKin non-kernel mode is onlyRT_TASK_PLACEHOLDERso i have no access tothread_base!Is there an official way to get this info (w/o opening "
/proc/xenomai/...")?
Not yet. You could extend RT_TASK_INFO with this statistic (obtained via rt_task_inquire). There is currently work in progress to add accumulated execution times to the same interface, so this extension would fit quite well. Patches always welcome.
Jan
Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Gsellmann Peter
Hi!
I searched for a while and found this snippet
RT_TASK*rt =rt_task_self();
int x =rt->thread_base.stat.csw;should give the number of context switches, but:
RT_TASKin non-kernel mode is onlyRT_TASK_PLACEHOLDERso i have no access tothread_base!
Quoted 8 lines
Quoted 3 lines
Is there an official way to get this info (w/o opening "
/proc/xenomai/...")?Not yet. You could extend
RT_TASK_INFOwith this statistic (obtained viart_task_inquire). There is currently work in progress to add accumulated execution times to the same interface, so this extension would fit quite well. Patches always welcome.
Meanwhile, I added this feature to my experimental patch stack while integrating some other new stats. See
http://www.rts.uni-hannover.de/rtaddon/patches/xenomai/
against Xenomai SVN trunk, namely
http://www.rts.uni-hannover.de/rtaddon/patches/xenomai/enhance-thread-stats.patch
Just call rt_task_inquire() and check RT_TASK_INFO::ctxswitches (there are modeswitches and pagefaults too as we are already at it).
Feedback welcome!
Jan