All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-core] ns vs. tsc as internal timer base
Date: Tue, 13 Jun 2006 15:28:41 +0200	[thread overview]
Message-ID: <448EBD89.4060003@domain.hid> (raw)
In-Reply-To: <17550.47269.736193.860722@domain.hid>

Gilles Chanteperdrix wrote:
> Philippe Gerum wrote:
>  > static inline unsigned long long ns_2_cycles(unsigned long long ns)
>  > {
>  >      return ns * ns2cyc_scale >> NS2CYC_SCALE_FACTOR;
> 
> This multiplication is 64 bits * 32 bits, the intermediate result may
> need more than 64 bits, so you should compute it the same way as the
> beginning of ullimd. Something like:

Sure, but the point is that if we were to use such code, we should bound 
the 64bit operand and would not use it beyond the tolerable loss of 
accuracy on output (e.g. 2ms).  This would require to break longer shots 
in several smaller ones, relying on the internal timer management logic 
to redo the shot until it has actually elapsed (which should be a rare 
case for oneshot timing), a bit like we are currently doing in bounding 
the values to 2^32-1 right now. Going for ullimd alike implementation 
somehow impedes the overall effort in reducing the CPU footprint, I 
guess. This said, I have still no clue if the gain in computation cycles 
is worth the additional overhead of dealing with possibly early shots - 
I tend to think it would be better on average though.

> 
> static inline unsigned long long ns_2_cycles(unsigned long long ns)
> {
>     unsigned nsh, nsl, tlh, tll;
>     unsigned long long th, tl;
> 
>     __rthal_u64tou32(ns, nsh, nsl);
>     tl = rthal_ullmul(nsl, ns2cyc_scale);
>     __rthal_u64tou32(tl, tlh, tll);
>     th = rthal_ullmul(nsh, ns2cyc_scale);
>     th += tlh;
> 
>     tll = (unsigned) th << (32 - NS2CYC_SCALE_FACTOR) | tll >> NS2CYC_SCALE_FACTOR;
>     th >>= NS2CYC_SCALE_FACTOR;
>     return __rthal_u64fromu32(th, tll);
> }
> 
> 


-- 

Philippe.


  reply	other threads:[~2006-06-13 13:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-13 10:51 [Xenomai-core] ns vs. tsc as internal timer base Jan Kiszka
2006-06-13 11:16 ` Philippe Gerum
2006-06-13 11:56   ` Jan Kiszka
2006-06-13 12:31     ` Philippe Gerum
2006-06-13 13:07       ` Gilles Chanteperdrix
2006-06-13 13:28         ` Philippe Gerum [this message]
2006-06-13 13:34           ` Gilles Chanteperdrix
2006-06-13 13:45             ` Philippe Gerum
2006-06-13 13:33       ` Jan Kiszka
2006-06-13 13:51         ` Philippe Gerum
2006-06-13 16:19       ` Jan Kiszka
2006-06-13 16:29         ` Gilles Chanteperdrix
2006-06-13 17:04         ` Philippe Gerum
2006-06-13 17:13           ` Gilles Chanteperdrix
2006-06-13 17:58             ` Philippe Gerum
2006-06-14  9:25               ` Jim Cromie
2006-06-14 12:29                 ` Philippe Gerum
2006-06-14 13:07                   ` Jan Kiszka
2006-06-14 16:04                     ` Jan Kiszka
2006-07-25 18:26             ` [Xenomai-core] Timer optimisations, continued Jan Kiszka
2006-07-27  8:53               ` Philippe Gerum
2006-07-27 12:42                 ` Gilles Chanteperdrix
2006-07-27 13:19                   ` Philippe Gerum
2006-07-27 13:54                     ` Jan Kiszka
2006-07-27 14:10                       ` Philippe Gerum
2006-06-13 11:59 ` [Xenomai-core] ns vs. tsc as internal timer base Gilles Chanteperdrix
2006-06-13 12:00 ` Anders Blomdell

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=448EBD89.4060003@domain.hid \
    --to=rpm@xenomai.org \
    --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.