From: Jan Kiszka <jan.kiszka@domain.hid>
To: xenomai-core <xenomai@xenomai.org>
Subject: [Xenomai-core] [PATCH 2/2] simplify xntimer_start
Date: Wed, 19 Jul 2006 01:48:43 +0200 [thread overview]
Message-ID: <44BD735B.2030502@domain.hid> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 315 bytes --]
Almost all callers of xntimer_start already run in nklock-protected
context. Therefore, we can save the lock reacquisition in that function
and turn it even into a trivial inliner. This patch also takes care of
the two exceptions of the rule above in xnpod_start_timer and psos+'s
tm_start_event_timer.
Jan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: xntimer-start-no-lock.patch --]
[-- Type: text/x-patch; name="xntimer-start-no-lock.patch", Size: 5864 bytes --]
---
include/nucleus/timer.h | 51 +++++++++++++++++++++++++++++++++++++++++++++---
ksrc/nucleus/pod.c | 2 +
ksrc/nucleus/timer.c | 49 ----------------------------------------------
ksrc/skins/psos+/tm.c | 4 ++-
4 files changed, 53 insertions(+), 53 deletions(-)
Index: include/nucleus/timer.h
===================================================================
--- include/nucleus/timer.h.orig
+++ include/nucleus/timer.h
@@ -290,9 +290,52 @@ void xntimer_init(xntimer_t *timer,
void xntimer_destroy(xntimer_t *timer);
-void xntimer_start(xntimer_t *timer,
- xnticks_t value,
- xnticks_t interval);
+/*!
+ * \fn void xntimer_start(xntimer_t *timer,xnticks_t value,xnticks_t interval)
+ * \brief Arm a timer.
+ *
+ * Activates a timer so that the associated timeout handler will be
+ * fired after each expiration time. A timer can be either periodic or
+ * single-shot, depending on the reload value passed to this
+ * routine. The given timer must have been previously initialized by a
+ * call to xntimer_init().
+ *
+ * @param timer The address of a valid timer descriptor.
+ *
+ * @param value The relative date of the initial timer shot, expressed
+ * in clock ticks (see note).
+ *
+ * @param interval The reload value of the timer. It is a periodic
+ * interval value to be used for reprogramming the next timer shot,
+ * expressed in clock ticks (see note). If @a interval is equal to
+ * XN_INFINITE, the timer will not be reloaded after it has expired.
+ *
+ * @return 0 is always returned.
+ *
+ * Environments:
+ *
+ * This service can be called from:
+ *
+ * - Kernel module initialization/cleanup code
+ * - Interrupt service routine
+ * - Kernel-based task
+ * - User-space task
+ *
+ * Rescheduling: never.
+ *
+ * @note This service is sensitive to the current operation mode of
+ * the system timer, as defined by the xnpod_start_timer() service. In
+ * periodic mode, clock ticks are interpreted as periodic jiffies. In
+ * oneshot mode, clock ticks are interpreted as nanoseconds.
+ *
+ * @note Must be called with nklock held, IRQs off.
+ */
+
+static inline void xntimer_start(xntimer_t *timer,
+ xnticks_t value, xnticks_t interval)
+{
+ nktimer->do_timer_start(timer, value, interval);
+}
/*!
* \fn int xntimer_stop(xntimer_t *timer)
@@ -315,6 +358,8 @@ void xntimer_start(xntimer_t *timer,
* - User-space task
*
* Rescheduling: never.
+ *
+ * @note Must be called with nklock held, IRQs off.
*/
static inline void xntimer_stop(xntimer_t *timer)
Index: ksrc/nucleus/pod.c
===================================================================
--- ksrc/nucleus/pod.c.orig
+++ ksrc/nucleus/pod.c
@@ -3095,8 +3095,10 @@ int xnpod_start_timer(u_long nstick, xni
xntimer_set_sched(&nkpod->htimer, xnpod_sched_slot(XNTIMER_KEEPER_ID));
+ xnlock_get_irqsave(&nklock, s);
xntimer_start(&nkpod->htimer, delta,
XNARCH_HOST_TICK / nkpod->tickvalue);
+ xnlock_put_irqrestore(&nklock, s);
return 0;
}
Index: ksrc/nucleus/timer.c
===================================================================
--- ksrc/nucleus/timer.c.orig
+++ ksrc/nucleus/timer.c
@@ -539,54 +539,6 @@ void xntimer_destroy(xntimer_t *timer)
timer->sched = NULL;
}
-/*!
- * \fn void xntimer_start(xntimer_t *timer,xnticks_t value,xnticks_t interval)
- * \brief Arm a timer.
- *
- * Activates a timer so that the associated timeout handler will be
- * fired after each expiration time. A timer can be either periodic or
- * single-shot, depending on the reload value passed to this
- * routine. The given timer must have been previously initialized by a
- * call to xntimer_init().
- *
- * @param timer The address of a valid timer descriptor.
- *
- * @param value The relative date of the initial timer shot, expressed
- * in clock ticks (see note).
- *
- * @param interval The reload value of the timer. It is a periodic
- * interval value to be used for reprogramming the next timer shot,
- * expressed in clock ticks (see note). If @a interval is equal to
- * XN_INFINITE, the timer will not be reloaded after it has expired.
- *
- * @return 0 is always returned.
- *
- * Environments:
- *
- * This service can be called from:
- *
- * - Kernel module initialization/cleanup code
- * - Interrupt service routine
- * - Kernel-based task
- * - User-space task
- *
- * Rescheduling: never.
- *
- * @note This service is sensitive to the current operation mode of
- * the system timer, as defined by the xnpod_start_timer() service. In
- * periodic mode, clock ticks are interpreted as periodic jiffies. In
- * oneshot mode, clock ticks are interpreted as nanoseconds.
- */
-
-void xntimer_start(xntimer_t *timer, xnticks_t value, xnticks_t interval)
-{
- spl_t s;
-
- xnlock_get_irqsave(&nklock, s);
- nktimer->do_timer_start(timer, value, interval);
- xnlock_put_irqrestore(&nklock, s);
-}
-
#if defined(CONFIG_SMP)
/**
* Migrate a timer.
@@ -776,7 +728,6 @@ xntmops_t *nktimer = &timer_ops_aperiodi
EXPORT_SYMBOL(xntimer_init);
EXPORT_SYMBOL(xntimer_destroy);
-EXPORT_SYMBOL(xntimer_start);
#if defined(CONFIG_SMP)
EXPORT_SYMBOL(xntimer_set_sched);
#endif /* CONFIG_SMP */
Index: ksrc/skins/psos+/tm.c
===================================================================
--- ksrc/skins/psos+/tm.c.orig
+++ ksrc/skins/psos+/tm.c
@@ -87,12 +87,14 @@ static u_long tm_start_event_timer(u_lon
tm->magic = PSOS_TM_MAGIC;
xnlock_get_irqsave(&nklock, s);
+
appendq(&psostimerq, &tm->link);
appendgq(&tm->owner->alarmq, tm);
- xnlock_put_irqrestore(&nklock, s);
xntimer_start(&tm->timerbase, ticks, interval);
+ xnlock_put_irqrestore(&nklock, s);
+
return SUCCESS;
}
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]
next reply other threads:[~2006-07-18 23:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-18 23:48 Jan Kiszka [this message]
2006-07-19 8:28 ` [Xenomai-core] [PATCH 2/2] simplify xntimer_start 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=44BD735B.2030502@domain.hid \
--to=jan.kiszka@domain.hid \
--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.