From: Jan Kiszka <jan.kiszka@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] Monotonic, realtime, and other timers
Date: Mon, 25 Jun 2007 16:34:03 +0200 [thread overview]
Message-ID: <467FD25B.1040607@domain.hid> (raw)
In-Reply-To: <467F9FE5.1070205@domain.hid>
[-- Attachment #1: Type: text/plain, Size: 6416 bytes --]
Jan Kiszka wrote:
> Gilles Chanteperdrix wrote:
>> Jan Kiszka wrote:
>> > Ok, I think it's time to summarise some results of this thread:
>> >
>> > - xntimers will be of three kinds: real-time absolute, monotonic
>> > absolute, and monotonic relative ones (ie. all POSIX). I'm currently
>> > in favour of passing this property on timer start and not pushing
>> > parts or more of it into timer init.
>>
>> The posix skin can live without monotonic absolute timers: monotonic
>> timeout could simply be converted to relative timeouts.
>>
>
> The POSIX skin will not be the only user, and I rather see disadvantages
> /wrt the hot-path (multiple timer readouts + conversions) when moving
> over emulation mode again.
>
> Anyway, I hope I can come up with some patches over the next days,
> clarifying what we actually need to change (not much I think).
Here is a first draft of a (hopefully final) xntimer_start API change.
Well, it does have some impact on this new interface and its users (but
those will need individual review anyway). So please let me know if you
think I'm on the right track -- before I generate useless changes.
Note: This snippet does not yet address isolated time bases or
re-adjustments of running timers with XNTIMER_REALTIME set. But that
will be straightforward then. Likely...
Jan
Index: xenomai/include/nucleus/timer.h
===================================================================
--- xenomai.orig/include/nucleus/timer.h
+++ xenomai/include/nucleus/timer.h
@@ -35,7 +35,9 @@
#define XNTIMER_DEQUEUED 0x00000001
#define XNTIMER_KILLED 0x00000002
#define XNTIMER_PERIODIC 0x00000004
-#define XNTIMER_MONOTONIC 0x00000008
+#define XNTIMER_REALTIME 0x00000008
+
+#define XNTIMER_ABSOLUTE 0x00000010 /* only used for timer start */
/* These flags are available to the real-time interfaces */
#define XNTIMER_SPARE0 0x01000000
@@ -47,6 +49,14 @@
#define XNTIMER_SPARE6 0x40000000
#define XNTIMER_SPARE7 0x80000000
+/* Timer operation modes */
+typedef enum xntimer_mode {
+ XNTM_MONOREL = 0,
+ XNTM_MONOABS = XNTIMER_ABSOLUTE,
+ XNTM_REALABS = XNTIMER_REALTIME | XNTIMER_ABSOLUTE
+} xntimer_mode_t;
+
+/* Timer priorities */
#define XNTIMER_LOPRIO (-999999999)
#define XNTIMER_STDPRIO 0
#define XNTIMER_HIPRIO 999999999
@@ -284,10 +294,6 @@ typedef struct xntimed_slave {
#endif /* !CONFIG_SMP */
#define xntimer_interval(t) ((t)->interval)
#define xntimer_set_cookie(t,c) ((t)->cookie = (c))
-#define xntimer_set_monotonic(t) \
- __setbits((t)->status, XNTIMER_MONOTONIC)
-#define xntimer_set_realtime(t) \
- __clrbits((t)->status, XNTIMER_MONOTONIC)
#ifdef CONFIG_XENO_OPT_TIMING_PERIODIC
#define xntimer_base(t) ((t)->base)
@@ -409,7 +415,7 @@ static inline void xntimer_set_name(xnti
static inline int xntimer_start(xntimer_t *timer,
xnticks_t value, xnticks_t interval,
- int mode)
+ xntimer_mode_t mode)
{
return timer->base->ops->start_timer(timer, value, interval, mode);
}
@@ -590,7 +596,7 @@ void xntslave_stop(xntslave_t *slave);
int xntimer_start_aperiodic(xntimer_t *timer,
xnticks_t value,
xnticks_t interval,
- int mode);
+ xntimer_mode_t mode);
void xntimer_stop_aperiodic(xntimer_t *timer);
@@ -604,7 +610,7 @@ xnticks_t xntimer_get_raw_expiry_aperiod
static inline int xntimer_start(xntimer_t *timer,
xnticks_t value, xnticks_t interval,
- int mode)
+ xntimer_mode_t mode)
{
return xntimer_start_aperiodic(timer, value, interval, mode);
}
Index: xenomai/include/nucleus/types.h
===================================================================
--- xenomai.orig/include/nucleus/types.h
+++ xenomai/include/nucleus/types.h
@@ -62,8 +62,6 @@ typedef int (*xniack_t)(unsigned irq);
#define XN_INFINITE (0)
#define XN_NONBLOCK ((xnticks_t)-1)
-#define XN_RELATIVE 0
-#define XN_ABSOLUTE 1
#define XN_APERIODIC_TICK 0
#define XN_NO_TICK ((xnticks_t)-1)
Index: xenomai/ksrc/nucleus/timer.c
===================================================================
--- xenomai.orig/ksrc/nucleus/timer.c
+++ xenomai/ksrc/nucleus/timer.c
@@ -91,7 +91,7 @@ static inline void xntimer_next_remote_s
int xntimer_start_aperiodic(xntimer_t *timer,
xnticks_t value, xnticks_t interval,
- int mode)
+ xntimer_mode_t mode)
{
xnticks_t date, now;
@@ -100,14 +100,20 @@ int xntimer_start_aperiodic(xntimer_t *t
now = xnarch_get_cpu_tsc();
- if (mode == XN_RELATIVE)
+ switch (mode) {
+ case XNTM_MONOREL:
date = xnarch_ns_to_tsc(value) + now;
- else {
- if (!testbits(timer->status, XNTIMER_MONOTONIC))
- value -= nktbase.wallclock_offset;
+ __clrbits(timer->status, XNTIMER_REALTIME);
+ break;
+ case XNTM_REALABS:
+ value -= nktbase.wallclock_offset;
+ /* fall through */
+ default: /* XNTM_MONOABS || XNTM_REALABS */
date = xnarch_ns_to_tsc(value);
if (date <= now)
return -ETIMEDOUT;
+ __setbits(timer->status, XNTIMER_REALTIME);
+ break;
}
xntimerh_date(&timer->aplink) = date;
@@ -282,18 +288,24 @@ static inline void xntimer_dequeue_perio
static int xntimer_start_periodic(xntimer_t *timer,
xnticks_t value, xnticks_t interval,
- int mode)
+ xntimer_mode_t mode)
{
if (!testbits(timer->status, XNTIMER_DEQUEUED))
xntimer_dequeue_periodic(timer);
- if (mode == XN_RELATIVE)
+ switch (mode) {
+ case XNTM_MONOREL:
value += timer->base->jiffies;
- else {
- if (!testbits(timer->status, XNTIMER_MONOTONIC))
- value -= timer->base->wallclock_offset;
+ __clrbits(timer->status, XNTIMER_REALTIME);
+ break;
+ case XNTM_REALABS:
+ value -= timer->base->wallclock_offset;
+ /* fall through */
+ default: /* XNTM_MONOABS || XNTM_REALABS */
if (value <= timer->base->jiffies)
return -ETIMEDOUT;
+ __setbits(timer->status, XNTIMER_REALTIME);
+ break;
}
xntlholder_date(&timer->plink) = value;
@@ -479,7 +491,7 @@ void xntslave_start(xntslave_t *slave, x
/* Spread ticks by timer latency to avoid too much nklock
contention and impose some servicing order. */
xntimer_start(&pc->timer, start + cpu * nklatency,
- interval, XN_ABSOLUTE);
+ interval, XNTM_MONOABS);
xnlock_put_irqrestore(&nklock, s);
}
}
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
next prev parent reply other threads:[~2007-06-25 14:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-23 8:08 [Xenomai-core] Monotonic, realtime, and other timers Jan Kiszka
2007-06-23 10:25 ` Philippe Gerum
2007-06-23 11:39 ` Jan Kiszka
2007-06-23 18:37 ` Philippe Gerum
2007-06-24 8:43 ` Jan Kiszka
2007-06-24 17:17 ` Gilles Chanteperdrix
2007-06-26 13:39 ` Jan Kiszka
2007-06-26 19:12 ` Gilles Chanteperdrix
2007-06-26 19:41 ` Jan Kiszka
2007-06-26 22:52 ` Gilles Chanteperdrix
2007-06-27 11:49 ` Jan Kiszka
2007-06-26 19:37 ` Philippe Gerum
2007-06-24 18:15 ` Philippe Gerum
2007-06-25 6:12 ` Jan Kiszka
2007-06-25 10:49 ` Gilles Chanteperdrix
2007-06-25 10:58 ` Jan Kiszka
2007-06-25 14:34 ` Jan Kiszka [this message]
2007-06-25 18:35 ` Gilles Chanteperdrix
2007-06-25 18:50 ` Jan Kiszka
2007-06-25 22:15 ` 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=467FD25B.1040607@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=gilles.chanteperdrix@xenomai.org \
--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.