All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Z <tomz30@yahoo.com>
To: xenomai@xenomai.org
Subject: [Xenomai] questions regarding context switch
Date: Thu, 21 Mar 2013 16:02:04 -0500	[thread overview]
Message-ID: <514B754C.4080800@yahoo.com> (raw)

Hi,

I have a user-space program that spawns 8 periodic RT_TASKs for 
execution. Each RT_TASK's code is very simple: it just loops for 10 
periods during each of which rt_timer_spin is called to consume some 
CPU. The periods of these RT_TASKs vary from 150 ms to 1 s, and during 
each of their periods, the RT_TASKs consume CPU for from 20 ms to 100 
ms, At the end of the program, I read rt_task_info::ctxswitches 
<http://www.xenomai.org/documentation/xenomai-2.6/html/api/structrt__task__info.html#a8d72c536900a743d462c8566ec28cab8> 
of one RT_TASK, and got 12, which means, if I understand it correctly, 
this task has 12 context switches during the program's execution. (The 
number of context switches of an RT_TASK should vary during each run of 
the program, but since my program is running only for a very short time, 
and only 8 RT_TASKs are running, this number should not vary much each 
time, and actually I got 12 each time I ran my program )

Now in addition to the execution of the above 8 RT_TASKs, I did an extra 
thing: I create a kernel module that setup a periodic RT_ALARM with a 
period of 250 us. This RT_ALARM starts immediately after the kernel 
module is loaded.The handler of this RT_ALARM simply increases a global 
counter by 1, so it gives the number of ALARM shots (expires).  Then I 
run the above user-space program again with the RT_ALARM being active, 
and after it finishes, I find that while the RT_ALARM has thousands of 
shots, the number of context switches ( rt_task_info::ctxswitches 
<http://www.xenomai.org/documentation/xenomai-2.6/html/api/structrt__task__info.html#a8d72c536900a743d462c8566ec28cab8>) 
of the task mentioned above is still 12. Here is what I don't 
understand: when an RT_ALARM expires and executes a handler, shouldn't 
there be a context switch if an RT_TASK is running? The task mentioned 
above executes rt_timer_spin for 100ms during each period, and the 
highest priority among all the 8 tasks, so while it is executing, the 
RT_ALARM must expire for many times -- but why does it NOT increase the 
number of the tasks' context switches?

Thanks,
Tom

             reply	other threads:[~2013-03-21 21:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-21 21:02 Tom Z [this message]
2013-03-21 21:07 ` [Xenomai] questions regarding context switch Gilles Chanteperdrix
2013-03-21 21:37   ` Tom Z

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=514B754C.4080800@yahoo.com \
    --to=tomz30@yahoo.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.