Skip to contentSkip to conversation

rt_cond_wait doesn't timeout (xenomai 2.4.1)

Xenomai-help Anders Blomdell 4 participants 13 messages Feb 29, 2008 – Mar 3, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

with xenomai 2.4.1 my call to:

  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

Regards

Anders Blomdell

Signature · 5 lines
Anders Blomdell                  Email: [email protected]
Department of Automatic Control
Lund University                  Phone:    +46 46 222 4625
P.O. Box 118                     Fax:      +46 46 138118
SE-221 00 Lund, Sweden
#1 lore raw
Quoted 8 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

Signature · 1 line
                                               Gilles Chanteperdrix
#2 lore raw
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 8 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

#include <sys/mman.h>
#include <native/cond.h>
#include <native/mutex.h>
#include <native/task.h>
#include <native/timer.h>

int main(int argc, char *argv[])
{
RT_MUTEX mutex;
RT_COND cond;
RT_TASK task_main;

  mlockall(MCL_CURRENT|MCL_FUTURE);

  rt_task_shadow(&task_main, "main", 1, T_FPU);
  if (rt_mutex_create(&mutex, NULL)) {
    fprintf(stderr, "Failed to create mutex\n");
    exit(1);
  }
  if (rt_cond_create (&cond, NULL)) {
    fprintf(stderr, "Failed to create condition\n");
    exit(1);
  }

  if (rt_timer_set_mode(TM_ONESHOT)) {
    fprintf(stderr, "Failed to set timer mode\n");
    exit(1);
  }

rt_mutex_acquire(&mutex, TM_INFINITE);
printf("A\n");
rt_cond_wait(&cond, &mutex, 1000);
printf("B\n");
rt_mutex_release(&mutex);
exit(0);
}

Probaly something extremely simple I have overlooked (SIGH).

Regards

Anders

Signature · 5 lines
Anders Blomdell                  Email: [email protected]
Department of Automatic Control
Lund University                  Phone:    +46 46 222 4625
P.O. Box 118                     Fax:      +46 46 138118
SE-221 00 Lund, Sweden
#3 lore raw
Quoted 7 lines · Anders Blomdell
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

I can't reproduce this issue with your test code here, but this might be the sign of some timer race depending on how fast is the hw.

By hanging, I assume the box is still ok, right?
If so, could you please send the output of /proc/xenomai/stat, /proc/xenomai/sched, /proc/xenomai/timer and /proc/xenomai/timerstat/master?

TIA,

Signature · 1 line
Philippe.
#4 lore raw
Quoted 21 lines · Philippe Gerum
Quoted 7 lines · Anders Blomdell
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

I can't reproduce this issue with your test code here, but this might be the sign of some timer race depending on how fast is the hw.

Quoted 7 lines

By hanging, I assume the box is still ok, right?
If so, could you please send the output of /proc/xenomai/stat, /proc/xenomai/sched, /proc/xenomai/timer and /proc/xenomai/timerstat/master?

TIA,

cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          108606586  0     00500080  100.0  ROOT/0
  0  0      0          54113426   0     00000082    0.0  rtnet-stack
  0  0      0          1          0     00000082    0.0  rtnet-rtpc
  0  22291  2          3          0     00300186    0.0  main
  0  0      0          107816863  0     00000000    0.0  IRQ22: rt_eepro100
  0  0      0          617309219  0     00000000    0.0  IRQ233: [timer]
Quoted 1 line

cat /proc/xenomai/sched

CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT/0
  0  0       98      0          0          master    W          rtnet-stack
  0  0        0      0          0          master    W          rtnet-rtpc
  0  22291    1      0          0          master    w          main
Quoted 1 line

cat /proc/xenomai/timer

status=on+watchdog:setup=0:clock=8061167744254256:timerdev=lapic:clockdev=tsc

Quoted 1 line

cat /proc/xenomai/timerstat/master

CPU  SCHEDULED   FIRED       TIMEOUT    INTERVAL   HANDLER      NAME
0    1049107334  506070537   324149     -          NULL         [host-timer/0]
0    3358790     3358789     662553305  1000000000  xnpod_watch  [watchdog]
0    1           1           -          -          xnthread_ti  main
Signature · 5 lines
Anders Blomdell                  Email: [email protected]
Department of Automatic Control
Lund University                  Phone:    +46 46 222 4625
P.O. Box 118                     Fax:      +46 46 138118
SE-221 00 Lund, Sweden
#5 lore raw
Quoted 43 lines · Anders Blomdell
Quoted 20 lines · Philippe Gerum
Quoted 7 lines · Anders Blomdell
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

I can't reproduce this issue with your test code here, but this might be the sign of some timer race depending on how fast is the hw.

Quoted 7 lines

By hanging, I assume the box is still ok, right?
If so, could you please send the output of /proc/xenomai/stat, /proc/xenomai/sched, /proc/xenomai/timer and /proc/xenomai/timerstat/master?

TIA,

cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          108606586  0     00500080  100.0  ROOT/0
  0  0      0          54113426   0     00000082    0.0  rtnet-stack
  0  0      0          1          0     00000082    0.0  rtnet-rtpc
  0  22291  2          3          0     00300186    0.0  main
  0  0      0          107816863  0     00000000    0.0  IRQ22: rt_eepro100
  0  0      0          617309219  0     00000000    0.0  IRQ233: [timer]
Quoted 1 line

cat /proc/xenomai/sched

CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT/0
  0  0       98      0          0          master    W          rtnet-stack
  0  0        0      0          0          master    W          rtnet-rtpc
  0  22291    1      0          0          master    w          main
Quoted 10 lines
Quoted 1 line

cat /proc/xenomai/timer

status=on+watchdog:setup=0:clock=8061167744254256:timerdev=lapic:clockdev=tsc

Quoted 1 line

cat /proc/xenomai/timerstat/master

CPU  SCHEDULED   FIRED       TIMEOUT    INTERVAL   HANDLER      NAME
0    1049107334  506070537   324149     -          NULL         [host-timer/0]
0    3358790     3358789     662553305  1000000000  xnpod_watch  [watchdog]
0    1           1           -          -          xnthread_ti  main

Thanks. It looks like the timer did tick but the wakeup event was missed. The thread is still waiting for it (stat xxxxxxx6 means delayed+pending, which is the mode rt_cond_wait() sets for the thread). We do have a problem, it seems.

Signature · 1 line
Philippe.
#6 lore raw
Quoted 55 lines · Philippe Gerum
Quoted 43 lines · Anders Blomdell
Quoted 20 lines · Philippe Gerum
Quoted 7 lines · Anders Blomdell
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

I can't reproduce this issue with your test code here, but this might be the sign of some timer race depending on how fast is the hw.

Quoted 7 lines

By hanging, I assume the box is still ok, right?
If so, could you please send the output of /proc/xenomai/stat, /proc/xenomai/sched, /proc/xenomai/timer and /proc/xenomai/timerstat/master?

TIA,

cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          108606586  0     00500080  100.0  ROOT/0
  0  0      0          54113426   0     00000082    0.0  rtnet-stack
  0  0      0          1          0     00000082    0.0  rtnet-rtpc
  0  22291  2          3          0     00300186    0.0  main
  0  0      0          107816863  0     00000000    0.0  IRQ22: rt_eepro100
  0  0      0          617309219  0     00000000    0.0  IRQ233: [timer]
Quoted 1 line

cat /proc/xenomai/sched

CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT/0
  0  0       98      0          0          master    W          rtnet-stack
  0  0        0      0          0          master    W          rtnet-rtpc
  0  22291    1      0          0          master    w          main
Quoted 10 lines
Quoted 1 line

cat /proc/xenomai/timer

status=on+watchdog:setup=0:clock=8061167744254256:timerdev=lapic:clockdev=tsc

Quoted 1 line

cat /proc/xenomai/timerstat/master

CPU  SCHEDULED   FIRED       TIMEOUT    INTERVAL   HANDLER      NAME
0    1049107334  506070537   324149     -          NULL         [host-timer/0]
0    3358790     3358789     662553305  1000000000  xnpod_watch  [watchdog]
0    1           1           -          -          xnthread_ti  main
Quoted 5 lines

Thanks. It looks like the timer did tick but the wakeup event was missed. The thread is still waiting for it (stat xxxxxxx6 means delayed+pending, which is the mode rt_cond_wait() sets for the thread). We do have a problem, it seems.

OK, what can I do to be of assistance?

/Anders

Signature · 5 lines
Anders Blomdell                  Email: [email protected]
Department of Automatic Control
Lund University                  Phone:    +46 46 222 4625
P.O. Box 118                     Fax:      +46 46 138118
SE-221 00 Lund, Sweden
#7 lore raw
Quoted 55 lines · Anders Blomdell
Quoted 54 lines · Philippe Gerum
Quoted 53 lines · Anders Blomdell
Quoted 20 lines · Philippe Gerum
Quoted 7 lines · Anders Blomdell
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

I can't reproduce this issue with your test code here, but this might be the sign of some timer race depending on how fast is the hw.

Quoted 7 lines

By hanging, I assume the box is still ok, right?
If so, could you please send the output of /proc/xenomai/stat, /proc/xenomai/sched, /proc/xenomai/timer and /proc/xenomai/timerstat/master?

TIA,

cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          108606586  0     00500080  100.0  ROOT/0
  0  0      0          54113426   0     00000082    0.0  rtnet-stack
  0  0      0          1          0     00000082    0.0  rtnet-rtpc
  0  22291  2          3          0     00300186    0.0  main
  0  0      0          107816863  0     00000000    0.0  IRQ22: rt_eepro100
  0  0      0          617309219  0     00000000    0.0  IRQ233: [timer]
Quoted 1 line

cat /proc/xenomai/sched

CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT/0
  0  0       98      0          0          master    W          rtnet-stack
  0  0        0      0          0          master    W          rtnet-rtpc
  0  22291    1      0          0          master    w          main
Quoted 1 line

cat /proc/xenomai/timer

status=on+watchdog:setup=0:clock=8061167744254256:timerdev=lapic:clockdev=tsc

Quoted 1 line

cat /proc/xenomai/timerstat/master

CPU  SCHEDULED   FIRED       TIMEOUT    INTERVAL   HANDLER      NAME
0    1049107334  506070537   324149     -          NULL         [host-timer/0]
0    3358790     3358789     662553305  1000000000  xnpod_watch  [watchdog]
0    1           1           -          -          xnthread_ti  main
Quoted 6 lines
Quoted 5 lines

Thanks. It looks like the timer did tick but the wakeup event was missed. The thread is still waiting for it (stat xxxxxxx6 means delayed+pending, which is the mode rt_cond_wait() sets for the thread). We do have a problem, it seems.

OK, what can I do to be of assistance?

Turn on the ipipe tracer (kernel config), tune it (/proc/ipipe/trace/post_trace_points to, say, 1000), let it triger on rt_cond_wait (echo rt_cond_wait > /proc/ipipe/trace/trigger), and fire up your test. The result will be in /proc/ipipe/trace/frozen.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#8 lore raw
In reply to Anders Blomdell
Quoted 55 lines · Anders Blomdell
Quoted 54 lines · Philippe Gerum
Quoted 53 lines · Anders Blomdell
Quoted 20 lines · Philippe Gerum
Quoted 7 lines · Anders Blomdell
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

I can't reproduce this issue with your test code here, but this might be the sign of some timer race depending on how fast is the hw.

Quoted 7 lines

By hanging, I assume the box is still ok, right?
If so, could you please send the output of /proc/xenomai/stat, /proc/xenomai/sched, /proc/xenomai/timer and /proc/xenomai/timerstat/master?

TIA,

cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          108606586  0     00500080  100.0  ROOT/0
  0  0      0          54113426   0     00000082    0.0  rtnet-stack
  0  0      0          1          0     00000082    0.0  rtnet-rtpc
  0  22291  2          3          0     00300186    0.0  main
  0  0      0          107816863  0     00000000    0.0  IRQ22: rt_eepro100
  0  0      0          617309219  0     00000000    0.0  IRQ233: [timer]
Quoted 1 line

cat /proc/xenomai/sched

CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT/0
  0  0       98      0          0          master    W          rtnet-stack
  0  0        0      0          0          master    W          rtnet-rtpc
  0  22291    1      0          0          master    w          main
Quoted 1 line

cat /proc/xenomai/timer

status=on+watchdog:setup=0:clock=8061167744254256:timerdev=lapic:clockdev=tsc

Quoted 1 line

cat /proc/xenomai/timerstat/master

CPU  SCHEDULED   FIRED       TIMEOUT    INTERVAL   HANDLER      NAME
0    1049107334  506070537   324149     -          NULL         [host-timer/0]
0    3358790     3358789     662553305  1000000000  xnpod_watch  [watchdog]
0    1           1           -          -          xnthread_ti  main
Quoted 7 lines
Quoted 5 lines

Thanks. It looks like the timer did tick but the wakeup event was missed. The thread is still waiting for it (stat xxxxxxx6 means delayed+pending, which is the mode rt_cond_wait() sets for the thread). We do have a problem, it seems.

OK, what can I do to be of assistance?

Are you running the application over GDB?

Signature · 1 line
Philippe.
#9 lore raw
Quoted 62 lines · Philippe Gerum
Quoted 60 lines · Anders Blomdell
Quoted 59 lines · Philippe Gerum
Quoted 43 lines · Anders Blomdell
Quoted 20 lines · Philippe Gerum
Quoted 7 lines · Anders Blomdell
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

I can't reproduce this issue with your test code here, but this might be the sign of some timer race depending on how fast is the hw.

Quoted 7 lines

By hanging, I assume the box is still ok, right?
If so, could you please send the output of /proc/xenomai/stat, /proc/xenomai/sched, /proc/xenomai/timer and /proc/xenomai/timerstat/master?

TIA,

cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          108606586  0     00500080  100.0  ROOT/0
  0  0      0          54113426   0     00000082    0.0  rtnet-stack
  0  0      0          1          0     00000082    0.0  rtnet-rtpc
  0  22291  2          3          0     00300186    0.0  main
  0  0      0          107816863  0     00000000    0.0  IRQ22: rt_eepro100
  0  0      0          617309219  0     00000000    0.0  IRQ233: [timer]
Quoted 1 line

cat /proc/xenomai/sched

CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT/0
  0  0       98      0          0          master    W          rtnet-stack
  0  0        0      0          0          master    W          rtnet-rtpc
  0  22291    1      0          0          master    w          main
Quoted 10 lines
Quoted 1 line

cat /proc/xenomai/timer

status=on+watchdog:setup=0:clock=8061167744254256:timerdev=lapic:clockdev=tsc

Quoted 1 line

cat /proc/xenomai/timerstat/master

CPU  SCHEDULED   FIRED       TIMEOUT    INTERVAL   HANDLER      NAME
0    1049107334  506070537   324149     -          NULL         [host-timer/0]
0    3358790     3358789     662553305  1000000000  xnpod_watch  [watchdog]
0    1           1           -          -          xnthread_ti  main

Thanks. It looks like the timer did tick but the wakeup event was missed. The thread is still waiting for it (stat xxxxxxx6 means delayed+pending, which is the mode rt_cond_wait() sets for the thread). We do have a problem, it seems.

Quoted 4 lines
Quoted 2 lines

OK, what can I do to be of assistance?

Are you running the application over GDB?

Cannot this be that the constant (3) used in rthal_timer_program_shot is a bit too small ?

Signature · 1 line
                                               Gilles Chanteperdrix
#10 lore raw
Quoted 62 lines · Gilles Chanteperdrix
Quoted 61 lines · Philippe Gerum
Quoted 60 lines · Anders Blomdell
Quoted 59 lines · Philippe Gerum
Quoted 43 lines · Anders Blomdell
Quoted 20 lines · Philippe Gerum
Quoted 7 lines · Anders Blomdell
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

I can't reproduce this issue with your test code here, but this might be the sign of some timer race depending on how fast is the hw.

Quoted 7 lines

By hanging, I assume the box is still ok, right?
If so, could you please send the output of /proc/xenomai/stat, /proc/xenomai/sched, /proc/xenomai/timer and /proc/xenomai/timerstat/master?

TIA,

cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          108606586  0     00500080  100.0  ROOT/0
  0  0      0          54113426   0     00000082    0.0  rtnet-stack
  0  0      0          1          0     00000082    0.0  rtnet-rtpc
  0  22291  2          3          0     00300186    0.0  main
  0  0      0          107816863  0     00000000    0.0  IRQ22: rt_eepro100
  0  0      0          617309219  0     00000000    0.0  IRQ233: [timer]
Quoted 1 line

cat /proc/xenomai/sched

CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT/0
  0  0       98      0          0          master    W          rtnet-stack
  0  0        0      0          0          master    W          rtnet-rtpc
  0  22291    1      0          0          master    w          main
Quoted 10 lines
Quoted 1 line

cat /proc/xenomai/timer

status=on+watchdog:setup=0:clock=8061167744254256:timerdev=lapic:clockdev=tsc

Quoted 1 line

cat /proc/xenomai/timerstat/master

CPU  SCHEDULED   FIRED       TIMEOUT    INTERVAL   HANDLER      NAME
0    1049107334  506070537   324149     -          NULL         [host-timer/0]
0    3358790     3358789     662553305  1000000000  xnpod_watch  [watchdog]
0    1           1           -          -          xnthread_ti  main

Thanks. It looks like the timer did tick but the wakeup event was missed. The thread is still waiting for it (stat xxxxxxx6 means delayed+pending, which is the mode rt_cond_wait() sets for the thread). We do have a problem, it seems.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

OK, what can I do to be of assistance?

Are you running the application over GDB?

Cannot this be that the constant (3) used in rthal_timer_program_shot is a bit too small ?

It indeed seems that the default calibration has been overridden using a zero value, but the timer object does elapse, so it is unlikely that a bad programming prevented the LAPIC from firing this shot. Looking at the thread timeout field, it also seems to confirm this, since a zero return means that the timer is inactive, i.e. it has been dequeued after the tick was processed.

This said, maybe we could try raising the default calibration dynamically to 1 us (> /proc/xenomai/latency), so that the I-pipe would be asked to handle the job directly for any earlier shot. Any change in behaviour would give us a hint about what goes wrong.

Signature · 1 line
Philippe.
#11 lore raw
In reply to Gilles Chanteperdrix
Quoted 62 lines · Gilles Chanteperdrix
Quoted 61 lines · Philippe Gerum
Quoted 60 lines · Anders Blomdell
Quoted 59 lines · Philippe Gerum
Quoted 43 lines · Anders Blomdell
Quoted 20 lines · Philippe Gerum
Quoted 7 lines · Anders Blomdell
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

I can't reproduce this issue with your test code here, but this might be the sign of some timer race depending on how fast is the hw.

Quoted 7 lines

By hanging, I assume the box is still ok, right?
If so, could you please send the output of /proc/xenomai/stat, /proc/xenomai/sched, /proc/xenomai/timer and /proc/xenomai/timerstat/master?

TIA,

cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          108606586  0     00500080  100.0  ROOT/0
  0  0      0          54113426   0     00000082    0.0  rtnet-stack
  0  0      0          1          0     00000082    0.0  rtnet-rtpc
  0  22291  2          3          0     00300186    0.0  main
  0  0      0          107816863  0     00000000    0.0  IRQ22: rt_eepro100
  0  0      0          617309219  0     00000000    0.0  IRQ233: [timer]
Quoted 1 line

cat /proc/xenomai/sched

CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT/0
  0  0       98      0          0          master    W          rtnet-stack
  0  0        0      0          0          master    W          rtnet-rtpc
  0  22291    1      0          0          master    w          main
Quoted 10 lines
Quoted 1 line

cat /proc/xenomai/timer

status=on+watchdog:setup=0:clock=8061167744254256:timerdev=lapic:clockdev=tsc

Quoted 1 line

cat /proc/xenomai/timerstat/master

CPU  SCHEDULED   FIRED       TIMEOUT    INTERVAL   HANDLER      NAME
0    1049107334  506070537   324149     -          NULL         [host-timer/0]
0    3358790     3358789     662553305  1000000000  xnpod_watch  [watchdog]
0    1           1           -          -          xnthread_ti  main

Thanks. It looks like the timer did tick but the wakeup event was missed. The thread is still waiting for it (stat xxxxxxx6 means delayed+pending, which is the mode rt_cond_wait() sets for the thread). We do have a problem, it seems.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

OK, what can I do to be of assistance?

Are you running the application over GDB?

Cannot this be that the constant (3) used in rthal_timer_program_shot is a bit too small ?

Some more info:

The problem is somewhat repeatable, running the following program sometimes brings back the problem. I'm beginning to think that the problem is that 'rt_task_delete(NULL);' doesn't release all thread resources (i.e. memory usage
grows continually [(i = 4999) => VmSize: 342504 kB). What have I misunderstood
about task deletion?

#include <sys/mman.h>
#include <native/cond.h>
#include <native/mutex.h>
#include <native/task.h>
#include <native/timer.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

static void suicide(void *arg)
{
printf("Suicide\n");
rt_task_delete(NULL);
}

int main(int argc, char *argv[])
{
RT_MUTEX mutex;
RT_TASK task_main;
RT_TASK task;
RT_COND cond;
int i;

  mlockall(MCL_CURRENT|MCL_FUTURE);

  rt_task_shadow(&task_main, "main", 1, T_FPU);
  if (rt_mutex_create(&mutex, NULL)) {
    fprintf(stderr, "Failed to create mutex\n");
    exit(1);
  }
  if (rt_cond_create (&cond, NULL)) {
    fprintf(stderr, "Failed to create condition\n");
    exit(1);
  }

  if (rt_timer_set_mode(TM_ONESHOT)) {
    fprintf(stderr, "Failed to set timer mode\n");
    exit(1);
  }

  for  (i = 0 ; i < 5000 ; i++) {
    if (i % 100 == 99) {
      int fd, N;
      char buf[1000];
      fd = open("/proc/self/status", O_RDONLY);
      while ((N = read(fd, buf, 1000)) > 0) {
        write(1, buf, N);
      }
      close(fd);
    }

    if (rt_task_create(&task, NULL, 0, 1, 0)) {
      fprintf(stderr, "Failed to create  task\n");
      exit(1);
    }
    if (rt_task_start(&task, &suicide, NULL)) {
      fprintf(stderr, "Failed to start task\n");
      exit(1);
    }
    rt_mutex_acquire(&mutex, TM_INFINITE);
    printf("i = %d\n", i);
    rt_cond_wait(&cond, &mutex, 5000000);
    printf("wait done\n");
    rt_mutex_release(&mutex);

}
exit(0);
}

Regards

/Anders

Signature · 5 lines
Anders Blomdell                  Email: [email protected]
Department of Automatic Control
Lund University                  Phone:    +46 46 222 4625
P.O. Box 118                     Fax:      +46 46 138118
SE-221 00 Lund, Sweden
#12 lore raw
In reply to Philippe Gerum
Quoted 55 lines · Philippe Gerum
Quoted 43 lines · Anders Blomdell
Quoted 20 lines · Philippe Gerum
Quoted 7 lines · Anders Blomdell
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Anders Blomdell

Hi,

with xenomai 2.4.1 my call to:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
  rt_cond_wait(&cond, &mutex, 1000);

doesn't timeout (signalling works OK). Kernel version is 2.6.23.12, can it be due to CONFIG_NO_HZ=y, or have I misunderstood something?

What is your system timer setting ? Are you running in periodic or aperiodic mode ? If aperiodic, 1000 ticks means 1000 ns, that is 1us, so rt_cond_wait should return instantaneously.

OK, here comes a simplified program that just outputs A, and then hangs.

I can't reproduce this issue with your test code here, but this might be the sign of some timer race depending on how fast is the hw.

Quoted 7 lines

By hanging, I assume the box is still ok, right?
If so, could you please send the output of /proc/xenomai/stat, /proc/xenomai/sched, /proc/xenomai/timer and /proc/xenomai/timerstat/master?

TIA,

cat /proc/xenomai/stat

CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          108606586  0     00500080  100.0  ROOT/0
  0  0      0          54113426   0     00000082    0.0  rtnet-stack
  0  0      0          1          0     00000082    0.0  rtnet-rtpc
  0  22291  2          3          0     00300186    0.0  main
  0  0      0          107816863  0     00000000    0.0  IRQ22: rt_eepro100
  0  0      0          617309219  0     00000000    0.0  IRQ233: [timer]
Quoted 1 line

cat /proc/xenomai/sched

CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT/0
  0  0       98      0          0          master    W          rtnet-stack
  0  0        0      0          0          master    W          rtnet-rtpc
  0  22291    1      0          0          master    w          main
Quoted 10 lines
Quoted 1 line

cat /proc/xenomai/timer

status=on+watchdog:setup=0:clock=8061167744254256:timerdev=lapic:clockdev=tsc

Quoted 1 line

cat /proc/xenomai/timerstat/master

CPU  SCHEDULED   FIRED       TIMEOUT    INTERVAL   HANDLER      NAME
0    1049107334  506070537   324149     -          NULL         [host-timer/0]
0    3358790     3358789     662553305  1000000000  xnpod_watch  [watchdog]
0    1           1           -          -          xnthread_ti  main
Quoted 5 lines

Thanks. It looks like the timer did tick but the wakeup event was missed. The thread is still waiting for it (stat xxxxxxx6 means delayed+pending, which is the mode rt_cond_wait() sets for the thread). We do have a problem, it seems.

Rebooting solved the problem this time (is this a Windows compatibility feature? :-)

Regards

Anders

Signature · 5 lines
Anders Blomdell                  Email: [email protected]
Department of Automatic Control
Lund University                  Phone:    +46 46 222 4625
P.O. Box 118                     Fax:      +46 46 138118
SE-221 00 Lund, Sweden