From: Jan Kiszka <jan.kiszka@domain.hid>
To: Xenomai core <Xenomai-core@domain.hid>
Subject: [Xenomai-core] [RFC][PATCH] nucleus: Prevent rescheduling while in xntbase_tick
Date: Fri, 17 Jun 2011 11:27:39 +0200 [thread overview]
Message-ID: <4DFB1E0B.1070903@domain.hid> (raw)
Based on code inspection, it looks like a timer handler triggering a
reschedule in the path xntbase_tick -> xntimer_tick_aperiodic /
xntimer_tick_periodic_inner -> handler can cause problems, e.g. a
reschedule before all expired timers were processed. The timer core is
usually run atomically from an interrupt handler, so better emulate an
IRQ context inside xntbase_tick by setting XNINIRQ.
This patch only affects users of xntbase_tick, ie. psos, vrtx and the
vxworks skin.
Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---
If my analysis is correct, this is also 2.5 material.
ksrc/nucleus/timebase.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/ksrc/nucleus/timebase.c b/ksrc/nucleus/timebase.c
index 6f7c02f..8f9af04 100644
--- a/ksrc/nucleus/timebase.c
+++ b/ksrc/nucleus/timebase.c
@@ -477,12 +477,16 @@ EXPORT_SYMBOL_GPL(xntbase_stop);
void xntbase_tick(xntbase_t *base)
{
+ struct xnsched_t *sched;
spl_t s;
xnlock_get_irqsave(&nklock, s);
trace_mark(xn_nucleus, tbase_tick, "base %s", base->name);
+ ++sched->inesting;
+ __setbits(sched->lflags, XNINIRQ);
+
if (base == &nktbase)
xntimer_tick_aperiodic();
else {
@@ -490,6 +494,11 @@ void xntbase_tick(xntbase_t *base)
xntimer_tick_periodic_inner(slave);
}
+ if (--sched->inesting == 0) {
+ __clrbits(sched->lflags, XNINIRQ);
+ xnpod_schedule();
+ }
+
xnlock_put_irqrestore(&nklock, s);
}
EXPORT_SYMBOL_GPL(xntbase_tick);
--
1.7.1
next reply other threads:[~2011-06-17 9:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-17 9:27 Jan Kiszka [this message]
2011-06-17 10:58 ` [Xenomai-core] [RFC][PATCH] nucleus: Prevent rescheduling while in xntbase_tick Gilles Chanteperdrix
2011-06-17 11:03 ` Jan Kiszka
2011-06-17 11:58 ` Philippe Gerum
2011-06-17 12:11 ` Jan Kiszka
2011-06-17 12:12 ` Philippe Gerum
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=4DFB1E0B.1070903@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=Xenomai-core@domain.hid \
/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.