Skip to contentSkip to conversation

accessing context switch counter from rttask

Xenomai-help Gsellmann Peter 2 participants 3 messages Jun 26, 2007 – Jul 8, 2007

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
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_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/...")?

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

#2 lore raw
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_TASK in non-kernel mode is only RT_TASK_PLACEHOLDER so i have no access to thread_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_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.

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