From: Reinhard Meyer <u-boot@emk-elektronik.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] ARM timing code refactoring
Date: Sun, 23 Jan 2011 19:47:24 +0100 [thread overview]
Message-ID: <4D3C77BC.50006@emk-elektronik.de> (raw)
In-Reply-To: <20110123162312.CDEDE1365DB@gemini.denx.de>
Dear Wolfgang Denk,
> Dear Reinhard Meyer,
>
> In message<4D3C0271.4070306@emk-elektronik.de> you wrote:
>>
>> There were several suggestions about that in the past (including from me)
>> that involve rework everywhere HZ related timeouts are used. I still
>> prefer a method as follows (because it does not need repeated mul/div calculations
>> nor necessarily 64 bit arithmetic):
>>
>> u32 timeout = timeout_init(100); /* 100ms timeout */
>>
>> do {...} while (!timed_out(timeout));
>
> I dislike this approach. I immediately fear the same problem I just
> saw (incorrectly) in Albert's proposal - timeout_init() seems to
> store the timeouut information in some internal varoable, which is
> then checked by timed_out() - this is bound to fail as soon as
> somebody atttempts to nest timeouts.
Excuse me: the timeout info is stored in the user's variable "timeout",
that should be quite obvious!
Nested timeouts pose no problem as long as the user uses different (local)
vars to store the return value of timeout_init().
>
> Your implementation may be different, but you can bet sooner or later
> comes up with such a bugy implementation.
There is nothing buggy.
>
> And it is not needed.
>
> PLease see my proposal: we do not needs several timer or timeout
> related functions, all we need is a plain "get timer" function,
> without any arguments. And the resulting code makes it obvious to the
> reader that such loops can be nested as you like.
>
If you demand that this get_timer returns in HZ units,
that will not be possible on most hardware without complicated code.
We have discussed that long ago...
>> time_out(x):
>> return ((i32)(x - fast_tick))< 0;
>>
>> If the tick were really high speed (and then 64 bits),
>> fast_tick could be derived by shifting the tick some bits to the right.
>
> I have no idea what "fast_tick" versus "tick" means here, nor why we
> would need more than one tick.
Well, you could try to understand:
tick=the "at hardware speed running" timer, if that's incrementing too fast for
32 bit "timeout" vars for reasonable timeouts (up to a minute?),
it could be divided by a power of two before use,
or we plainly use u64 for the "timeout" variables; probably simpler than shifting...
Reinhard
next prev parent reply other threads:[~2011-01-23 18:47 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-22 10:20 [U-Boot] [RFC] ARM timing code refactoring Albert ARIBAUD
2011-01-22 10:42 ` Reinhard Meyer
2011-01-22 11:32 ` Albert ARIBAUD
2011-01-22 11:00 ` [U-Boot] [RFC] U-boot (was: ARM) " Reinhard Meyer
2011-01-22 12:22 ` [U-Boot] [RFC] U-boot Albert ARIBAUD
2011-01-22 19:19 ` [U-Boot] [RFC] ARM timing code refactoring Wolfgang Denk
2011-01-22 20:17 ` Albert ARIBAUD
2011-01-22 21:26 ` Wolfgang Denk
2011-01-22 21:51 ` Reinhard Meyer
2011-01-23 10:12 ` Wolfgang Denk
2011-01-23 10:26 ` Reinhard Meyer
2011-01-23 16:23 ` Wolfgang Denk
2011-01-23 18:47 ` Reinhard Meyer [this message]
2011-01-23 19:35 ` Wolfgang Denk
2011-01-23 20:59 ` Albert ARIBAUD
2011-01-23 21:22 ` Reinhard Meyer
2011-01-23 22:01 ` Reinhard Meyer
2011-01-23 22:57 ` Wolfgang Denk
2011-01-24 1:42 ` J. William Campbell
2011-01-24 7:24 ` Albert ARIBAUD
2011-01-24 7:50 ` Reinhard Meyer
2011-01-24 12:59 ` Wolfgang Denk
2011-01-24 8:25 ` Andreas Bießmann
2011-01-24 11:58 ` Albert ARIBAUD
2011-01-24 12:06 ` Albert ARIBAUD
2011-01-24 12:58 ` Andreas Bießmann
2011-01-24 12:54 ` Wolfgang Denk
2011-01-24 13:02 ` Wolfgang Denk
2011-01-24 16:23 ` J. William Campbell
2011-01-22 22:13 ` Albert ARIBAUD
2011-01-23 16:15 ` Wolfgang Denk
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=4D3C77BC.50006@emk-elektronik.de \
--to=u-boot@emk-elektronik.de \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox