All of lore.kernel.org
 help / color / mirror / Atom feed
From: Per Oberg <pero@wolfram.com>
To: Paolo Minazzi <Paolo.Minazzi@mitrol.it>
Cc: xenomai <xenomai@xenomai.org>
Subject: Re: Question about gdb and timeout
Date: Thu, 8 Oct 2020 11:31:43 -0500 (CDT)	[thread overview]
Message-ID: <1908941175.1265140.1602174703558.JavaMail.zimbra@wolfram.com> (raw)
In-Reply-To: <6c79c68d-fa03-28cd-71e5-d02f1be7d6a2@mitrol.it>



----- Den 8 okt 2020, på kl 14:47, xenomai xenomai@xenomai.org skrev:

> Hi to all,
> I have an ARM board (iMX6SX).
> - kernel 4.9.88
> - xenomai 3.0.9
> - ipipe-core-4.9.51-arm-4

> I have run a simple xenomai alchemy test :
> - a task that wait an event (timeout 10 secs)
> - a task that signal the event (every 100 msecs)
> All works correctly.

> When I use the example with gdb:
> b 56 (at usleep(10000) in the main)
> r
> c
> c
> ...
> If I stay stopped in gdb for more that 10 seconds (that is the timeout
> of the rt_event_wait), I get -110 (= -ETIMEDOUT).
> This because I think the timer counts also when tasks are stopped in gdb.
> Is there a way to avoid this behavior ? When I'm stopped in gdb, the
> real-time"world" should be stopped.

This is not exactly my home arena, but I'm waiting for a kernel compile so I'll give you my two cents...

Not easily, or plainly just no. At least not without rewriting your timeout code. I'm not sure what alchemy uses as base clock for it's timers, but for the posix skin you have the option of CLOCK_HOST and CLOCK_HOST_REALTIME, CLOCK_MONOTONIC and CLOCK_REALTIME (and maybe others) that represents the Linux kernel time and the Xenomai kernel time. Gdb just stops your application while the kernel timers will keep running.

However, If you base a timer on the linux CLOCK_REALTIME and reset the linux host time before your timer times out you could be able to trick it. The difference between CLOCK_MONOTONIC and CLOCK_REALTIME is that CLOCK_REALTIME can jump backwards, e.g. when a NTP client resets it, although I am not sure what this does to different timers.

Per Öberg 

> Thanks for your support,
> Best regards,
> Paolo

> #include <stdlib.h>
> #include <stdio.h>
> #include <alchemy/task.h>
> #include <alchemy/event.h>

> RT_TASK rt_task_wait,
> rt_task_signal;
> volatile unsigned int cnt;

> #define EVENT_WAIT_MASK 1

> RT_EVENT ev;

> #define MSEC(x) (RTIME)((x) * 1000ULL * 1000ULL)
> #define SEC(x) (RTIME)(MSEC(x) * 1000ULL)

> void xeno_task_wait(void *dummy)
> {
> unsigned int mask_ret;
> rt_event_create(&ev, "ev", 0, 0);
> RTIME timeout = SEC(10);
> while(1)
> {
> cnt++;
> int res;
> res = rt_event_wait(&ev, EVENT_WAIT_MASK, &mask_ret, EV_ANY,
> timeout);
> if (res)
> {
> printf(">>> res = %d\n", res);
> exit(0);
> }
> rt_event_clear(&ev, EVENT_WAIT_MASK, &mask_ret);
> }
> }

> void xeno_task_signal(void *dummy)
> {
> while(1)
> {
> rt_task_sleep( MSEC(100) );
> rt_event_signal(&ev, EVENT_WAIT_MASK);
> }
> }

> int main(int argc, char *const *argv)
> {
> rt_task_create(&rt_task_wait, "wait", 0, 98, 0);
> rt_task_start (&rt_task_wait, &xeno_task_wait, NULL);

> rt_task_create(&rt_task_signal, "signal", 0, 99, 0);
> rt_task_start (&rt_task_signal, &xeno_task_signal, NULL);

> while(1)
> {
> usleep(10000); // <<<============ BREAKPOINT
> printf("%d\n", cnt);
> }
> }


  reply	other threads:[~2020-10-08 16:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08 12:47 Question about gdb and timeout Paolo Minazzi
2020-10-08 16:31 ` Per Oberg [this message]
2020-10-12 10:36   ` Jan Kiszka
2020-10-13  6:44     ` Paolo Minazzi

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=1908941175.1265140.1602174703558.JavaMail.zimbra@wolfram.com \
    --to=pero@wolfram.com \
    --cc=Paolo.Minazzi@mitrol.it \
    --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.