All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] task rate control with alarm and semaphore
@ 2007-10-31 10:45 MEYLAN Jean-philippe
  2007-10-31 17:45 ` ROSSIER Daniel
  2007-11-01 10:56 ` Jan Kiszka
  0 siblings, 2 replies; 6+ messages in thread
From: MEYLAN Jean-philippe @ 2007-10-31 10:45 UTC (permalink / raw)
  To: xenomai

Hello,

I'm working on the creation of a Xenomai target for Mathwork's
Real Time Workshop. In order to achieve this, I would like to 
control the execution rate of a task with a semaphore periodically
released by an alarm handler. The tasks does nothing else but waiting
(in a loop) on the semaphore. If the task can immediately take 
the sempahore, it means that the rate is too fast for it because
the semaphore has been released before the end of its current iteration.

My problem is that I cannot decrease the alarm period under 40us
without facing this situation. I cannot figure what is the cause of
all that overhead (maybe it comes from the rt_alarm_wait call ?). I
have tried to use event flags instead of semaphores but I get the
same results.

Do you have any idea ?

Here is the code of the main task and the alarm handler:

void tBaseRate(void * cookie)
{
  while (1) {
    if (rt_sem_p(&rtClockSem, TM_NONBLOCK) == 0) {
      printf("Rate for BaseRate task too fast.\n");
    } else {
      rt_sem_p(&rtClockSem, TM_INFINITE);
    }
}

void clockHandler(void * cookie)
{
  int status;
  while (1) {
    status = rt_alarm_wait(&clockDesc);
    if (!status) {
      status = rt_sem_v(&rtClockSem);
      if (status)
        printf ("Semaphore error : %d\n", status);
    } else
      printf ("Alarm error: %d\n", status);
  }
}

Thank you very much.

Best regards,

Jean-Philippe Meylan


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

end of thread, other threads:[~2007-11-01 15:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-31 10:45 [Xenomai-help] task rate control with alarm and semaphore MEYLAN Jean-philippe
2007-10-31 17:45 ` ROSSIER Daniel
2007-10-31 19:21   ` Gilles Chanteperdrix
2007-11-01  8:25     ` ROSSIER Daniel
2007-11-01 15:21       ` Philippe Gerum
2007-11-01 10:56 ` Jan Kiszka

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.