From: Albert ARIBAUD <albert.aribaud@free.fr>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] ARM timing code refactoring
Date: Sat, 22 Jan 2011 23:13:33 +0100 [thread overview]
Message-ID: <4D3B568D.3080903@free.fr> (raw)
In-Reply-To: <20110122212601.9C8A2B187@gemini.denx.de>
Le 22/01/2011 22:26, Wolfgang Denk a ?crit :
>> Hmm... My idea with providing time() with an argument was that precisely
>> since we are interested only in elapsed time, not absolute time, our
>> basic time function should be able to tell us relative times.
>
> The disadvantage of this approach is that such calls cannot be nested,
> i. e. you must always make sure that the code run within the timeout
> loop does not attempt to set up a timeout on it's own. From my point
> of view, this is a killing point.
>
>> Functionally this is the same as what I suggested, minus the absolute
>> get_timer() vs relative time(x) call. Either way works, I'm not going to
>> try and make a point that we use "my" time(x).
>
> See above for the fundamental difference - not in the implementation
> for a single timeout, but from a system-wide point of view.
>
>>>> then = time(0);
>>>> do {...} while ( time(then)< ms_to_ticks(100) );
>>>
>>> We should NOT do this. It is bound to break as soon as the code
>>> in the loop (the "..." part) needs to implement a timeout, too.
>>
>> I'm not sure to understand why. Can you develop how you think this would
>> break with an inner timeout?
>
> Sure:
>
> /* implement something which needs a 100 ms timeout */
> then = time(0);
>
> do {
> int then_nested;
> ... do something...
> ... do more...
> /* now do something which needs a 5 ms timeout */
> then_nested = time(0);
> do {
> ...
> } while (time(then_nested)< ms_to_ticks(5));
>
> } while (time(then)< ms_to_ticks(100));
>
> You see the problem?
Actually no, I don't. As a reminder, I am considering the following
definitions:
#define time(n) (ticks-n)
#define ms_to_ticks(ms) (ms * fast_tick_rate) / CONFIG_SYS_HZ
Neither of these has any side effect, so I am at loss as to why that
would break when used in nested loops; each loop has its own reference
start time by assigning time(0) to its own variable (then and
then_nested), and each has its own elapsed time computation by passing
its own variable to time() and comparing with its own constant timeout
value. Can you point the exact instruction that would break in the code
above, and why it would?
> Best regards,
>
> Wolfgang Denk
Amicalement,
--
Albert.
next prev parent reply other threads:[~2011-01-22 22:13 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
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 [this message]
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=4D3B568D.3080903@free.fr \
--to=albert.aribaud@free.fr \
--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