All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Matthias Schneider <ma30002000@yahoo.de>,
	"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] issue with cobalt/timer: avoid periodic timer drift
Date: Sun, 06 Jul 2014 19:04:56 +0200	[thread overview]
Message-ID: <53B981B8.5070901@xenomai.org> (raw)
In-Reply-To: <1404640109.73994.YahooMailNeo@web171603.mail.ir2.yahoo.com>

On 07/06/2014 11:48 AM, Matthias Schneider wrote:
> Hi all,
> 
> commit 
> 
> 2014-06-02 c20fceb147e337e2379b29ecd81b943318c7fbc7 
> (patch) cobalt/timer: avoid periodic timer drift
> 
> seems to cause an endless kernel loop in one of my
> freertos demos. The issue does not occur when 
> reverting this commit.
> 
> Investigating the issue, can see the following:
> 
> #0  0xc00ba45c in mach_arm_nodiv_llimd (rhs_integ=<optimized out>, frac=<optimized out>, op=<optimized out>)
>     at arch/arm/xenomai/include/asm/xenomai/uapi/arith.h:120
> #1  xnclock_core_ns_to_ticks (ns=0) at kernel/xenomai/clock.c:52
> #2  0xc00baf34 in xnclock_ns_to_ticks (clock=<optimized out>, ns=<optimized out>)
>     at include/xenomai/cobalt/kernel/clock.h:204
> #3  xntimer_update_date (timer=0xde706518) at include/xenomai/cobalt/kernel/timer.h:268
> #4  xnclock_tick (clock=0xc06b1138 <nkclock>) at kernel/xenomai/clock.c:644
> #5  0xc00bcbcc in xnintr_core_clock_handler () at kernel/xenomai/intr.c:121
> #6  0xc0095a98 in dispatch_irq_head (irq=<optimized out>) at kernel/ipipe/core.c:1179
> 
> This seems to be the endless loop:
> 642                     do {
> 643      timer->periodic_ticks += interval_ticks;
> 644      xntimer_update_date(timer);
> 645                     } while (xntimerh_date(&timer->aplink) < now + clock->gravity);


I do not really understand how interval_ticks can be 0, but please try 
the following patch:

diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index a578f89..1107f7a 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -619,10 +619,9 @@ void xnclock_tick(struct xnclock *clock)
 			 * wait for 250 ms for the user to continue
 			 * program execution.
 			 */
-			if (timer->interval_ns > 250000000)
-				goto advance;
-			interval_ticks = 250000000 /
-				(unsigned)timer->interval_ns;
+			xntimerh_date(&timer->aplink) +=
+				xnclock_ns_to_ticks(xntimer_clock(timer),
+						250000000);
 			goto requeue;
 		}
 	fire:
@@ -638,11 +637,11 @@ void xnclock_tick(struct xnclock *clock)
 			continue;
 	advance:
 		interval_ticks = 1;
-	requeue:
 		do {
 			timer->periodic_ticks += interval_ticks;
 			xntimer_update_date(timer);
 		} while (xntimerh_date(&timer->aplink) < now + clock->gravity);
+	requeue:
 #ifdef CONFIG_SMP
 		/*
 		 * Make sure to pick the right percpu queue, in case



-- 
                                                                Gilles.


  parent reply	other threads:[~2014-07-06 17:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-06  9:48 [Xenomai] issue with cobalt/timer: avoid periodic timer drift Matthias Schneider
2014-07-06 12:50 ` Philippe Gerum
2014-07-06 15:01 ` Gilles Chanteperdrix
2014-07-06 16:00   ` Matthias Schneider
2014-07-06 16:09     ` Gilles Chanteperdrix
2014-07-06 16:31       ` Matthias Schneider
2014-07-06 16:37         ` Matthias Schneider
2014-07-06 16:44           ` Gilles Chanteperdrix
2014-07-06 16:56             ` Matthias Schneider
2014-07-06 16:57               ` Gilles Chanteperdrix
2014-07-06 17:04 ` Gilles Chanteperdrix [this message]
2014-07-06 17:36   ` Matthias Schneider

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=53B981B8.5070901@xenomai.org \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=ma30002000@yahoo.de \
    --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.