All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] rt_task_sleep_until question
@ 2008-04-11 16:09 Klaas Gadeyne
  2008-04-12 13:11 ` Jan Kiszka
  0 siblings, 1 reply; 20+ messages in thread
From: Klaas Gadeyne @ 2008-04-11 16:09 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: TEXT/PLAIN, Size: 867 bytes --]

Hi,

I've noticed that threads which, in my ignorant opinion, are supposed
to be sleeping, get woken up much earlier than I expect them to be.

Please find attached a modified version of the trivial-periodic.c
application, which creates a RT_TASK that should sleep as long as
possible (i.e. until unblocked by a signal handler).  However, the
task gets woken up much earlier (and many times) _before_ that time it
seems.

  head /tmp/app.txt
current_time = 1207928393295939429
sleep until 18446744073709551615
[TIMERLOOP] Total errors = 1, return code = -110
current_time = 1207928393296000379
sleep until 18446744073709551615
[TIMERLOOP] Total errors = 2, return code = -110
current_time = 1207928393296005409
sleep until 18446744073709551615
[TIMERLOOP] Total errors = 3, return code = -110
current_time = 1207928393296009604

What did I overlook here?

Thx,

Klaas

[-- Attachment #2: Type: TEXT/x-csrc, Size: 1417 bytes --]

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>

#include <native/task.h>
#include <native/timer.h>

RT_TASK demo_task;
char stop_timer=0;
#define TIMEVAL_MAX ~(RTIME)0

void demo(void *arg)
{
  int ret; 
  int errors = 0;
  do{
    do{
      printf("current_time = %llu\n",rt_timer_read());
      printf("sleep until %llu\n", TIMEVAL_MAX);
    }while ((ret = rt_task_sleep_until(TIMEVAL_MAX)) == 0);
    //		if (ret == -ETIMEDOUT){
    printf("[TIMERLOOP] Total errors = %d, return code = %d\n",++errors,ret);
    // }
  }while (!(stop_timer && ret == -EINTR));
  printf("End of TimerLoop, code %d, Total errors = %d\n",ret,errors);
}

void catch_signal(int sig)
{
  stop_timer = 1;
  rt_task_unblock(&demo_task);
}

int main(int argc, char* argv[])
{
  signal(SIGTERM, catch_signal);
  signal(SIGINT, catch_signal);

  /* Avoids memory swapping for this program */
  mlockall(MCL_CURRENT|MCL_FUTURE);

  /*
   * Arguments: &task,
   *            name,
   *            stack size (0=default),
   *            priority,
   *            mode (FPU, start suspended, ...)
   */
  rt_task_create(&demo_task, "sleeping forever", 0, 50, 0);

  /*
   * Arguments: &task,
   *            task function,
   *            function argument
   */
  rt_task_start(&demo_task, &demo, NULL);

  pause();

  rt_task_delete(&demo_task);
}

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

end of thread, other threads:[~2008-08-02 12:24 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-11 16:09 [Xenomai-help] rt_task_sleep_until question Klaas Gadeyne
2008-04-12 13:11 ` Jan Kiszka
2008-04-12 15:32   ` klaas.gadeyne
2008-04-12 16:01     ` Gilles Chanteperdrix
2008-04-17 15:23       ` Klaas Gadeyne
2008-04-17 15:30         ` Gilles Chanteperdrix
2008-04-17 15:46           ` Gilles Chanteperdrix
2008-04-17 16:07             ` Philippe Gerum
2008-04-17 16:39               ` Gilles Chanteperdrix
2008-04-22 13:45               ` Klaas Gadeyne
2008-04-22 13:49                 ` Philippe Gerum
2008-04-22 14:25                   ` Klaas Gadeyne
2008-04-22 20:56                     ` Philippe Gerum
2008-04-23 11:27                       ` Klaas Gadeyne
2008-04-23 11:37                         ` Philippe Gerum
2008-04-23 12:53                           ` Bosko Radivojevic
2008-04-23 17:43                             ` Philippe Gerum
2008-08-01 23:07                   ` [Xenomai-help] Recurring Interrupts Henry Bausley
2008-08-02  7:38                     ` Philippe Gerum
2008-08-02 12:24                       ` Philippe Gerum

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.