From: Reinhard Meyer <u-boot@emk-elektronik.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC][Timer API] Revised Specification - Implementation details
Date: Tue, 31 May 2011 07:16:03 +0200 [thread overview]
Message-ID: <4DE47993.2020104@emk-elektronik.de> (raw)
In-Reply-To: <BANLkTikZUkk1EaYqCg=5mB2npva2iE6Lew@mail.gmail.com>
Dear Graeme Russ,
> On Tue, May 31, 2011 at 2:53 PM, Reinhard Meyer
> <u-boot@emk-elektronik.de> wrote:
>> Dear Simon Glass,
>>
>>> On Mon, May 30, 2011 at 5:24 PM, Graeme Russ<graeme.russ@gmail.com>
>>> wrote:
>>>>
>>>> Hi Reinhard,
>>>>
>>>> On Tue, May 31, 2011 at 4:57 AM, Reinhard Meyer
>>>
>>> ...
>>>>>
>>>>> make_timeout() can be arch/soc/platform specific and take into account
>>>>> to return at least
>>>>> such a value that the timeout is never cut short. (In case of a 10 ms
>>>>> NIOS timer,
>>>>> make_timeout(5) would have to return the value 20, resulting in a real
>>>>> timeout of at least
>>>>> 10 ms but upto 20 ms )
>>>>
>>>> What about this:
>>>>
>>>> u32 start = get_timer();
>>>>
>>>> while (!timer_expired(start, timeout))
>>>> ...
>>>>
>>>
>>> Hi Graham,
>>>
>>> I like this, although I have a small preference for:
>>>
>>> u32 stop = time_get_future_ms(1234);
>>>
>>> while (!time_reached(stop))
>>> ..
>>
>> I would perfectly like such a solution, it is equivalent to what I have been
>> proposing
>> almost a year ago!
>
> Don't forget the API will have a get_current_ms() so we can do duration
> measurements. So you could still accidentally do:
>
> u32 stop = get_current_ms() + 1234;
>
> bypassing the resolution correction. If time_reached() did the resolution
> correction, would this solve the problem of API misuse (yes, I know it puts
> a complicated calculation back in the loop)
>
>>> since it possibly means the processing happens up front. However any
>>> such function is good and I hope you can add it to your API.
>>
>> Exactly! And (saying it silently) this would not mandate that the now hidden
>> internal
>> timer needs to be in ms units, it could be the bare "natural" tick of the
>> hardware...
>> Making time_get_future() to return the "tick" (in whatever granularity) that
>> has to
>> be passed would reduce time_reached() to a very simple function.
>
> Half the point of refreshing the timer API was to solidify the fact that
> timers operate on a fixed time base (milliseconds or microseconds) so they
> can be used trivially for a variety of things (delays, timeouts, durations
> measurement etc). Ticks can be very short, so doing durations would require
> 64-bit 'start tick', and a conversion at the end:
>
> u64 start = get_current_tick();
> ... do something ...
> u32 duration = ticks_to_ms(get_current_tick() - start);
>
> Yetch! - We will not be exposing ticks!
Moot argument again. Any fast 64 bit tick can be very simply brought into
a 32 bit, just sub-ms granularity by a simple right shift. But I would also
be happy with 64 bits as well, since all calculations in the loop would be just
add/subtracts and no mul/divs.
>
>> But I get the feeling that exactly this simplicity of above concept is the
>> problem
>> for people that have the urge to invent elaborate and complicated solutions
>> ;)
>
> I like simple as much as the next guy - I also like hard to misuse ;)
typedefs would prevent accidental misuses, there is no cure against deliberate
misuses except peer review...
Reinhard
next prev parent reply other threads:[~2011-05-31 5:16 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-26 13:27 [U-Boot] [RFC][Timer API] Revised Specification - Implementation details Graeme Russ
2011-05-26 15:57 ` Simon Glass
2011-05-26 17:28 ` Wolfgang Denk
2011-05-26 22:44 ` Graeme Russ
2011-05-27 5:23 ` Simon Glass
2011-05-27 7:40 ` Wolfgang Denk
2011-05-27 14:46 ` Simon Glass
2011-05-26 16:56 ` J. William Campbell
2011-05-26 17:53 ` Wolfgang Denk
2011-05-26 18:52 ` J. William Campbell
2011-05-26 19:16 ` Wolfgang Denk
2011-05-26 19:54 ` J. William Campbell
2011-05-26 20:27 ` Wolfgang Denk
2011-05-26 20:39 ` J. William Campbell
2011-05-26 22:59 ` Graeme Russ
2011-05-26 23:28 ` Graeme Russ
2011-05-27 1:26 ` J. William Campbell
2011-05-27 1:51 ` Graeme Russ
2011-05-27 3:54 ` J. William Campbell
2011-05-27 4:33 ` Graeme Russ
2011-05-27 6:33 ` J. William Campbell
2011-05-27 6:54 ` Graeme Russ
2011-05-27 15:49 ` J. William Campbell
2011-05-28 0:32 ` Graeme Russ
2011-05-27 7:33 ` Wolfgang Denk
2011-05-27 14:16 ` J. William Campbell
2011-05-27 7:28 ` Wolfgang Denk
2011-05-27 14:04 ` J. William Campbell
2011-05-27 7:13 ` Wolfgang Denk
2011-05-27 7:35 ` Graeme Russ
2011-05-27 7:48 ` Wolfgang Denk
2011-05-27 7:57 ` Graeme Russ
2011-05-27 8:01 ` Graeme Russ
2011-05-27 11:27 ` Wolfgang Denk
2011-05-27 12:43 ` Graeme Russ
2011-05-27 13:07 ` Scott McNutt
2011-05-27 15:00 ` J. William Campbell
2011-05-27 15:13 ` Simon Glass
2011-05-27 17:11 ` J. William Campbell
2011-05-27 15:44 ` Scott McNutt
2011-05-27 15:59 ` J. William Campbell
2011-05-29 15:55 ` Wolfgang Denk
2011-05-29 19:12 ` Simon Glass
2011-05-30 10:57 ` Wolfgang Denk
2011-05-30 11:47 ` Graeme Russ
2011-05-30 12:31 ` Wolfgang Denk
2011-05-30 12:46 ` Graeme Russ
2011-05-30 18:57 ` Reinhard Meyer
2011-05-31 0:24 ` Graeme Russ
2011-05-31 4:07 ` Reinhard Meyer
2011-05-31 4:24 ` Graeme Russ
2011-05-31 4:36 ` Reinhard Meyer
2011-05-31 4:53 ` Graeme Russ
2011-05-31 5:56 ` Wolfgang Denk
2011-05-31 4:45 ` Simon Glass
2011-05-31 4:53 ` Reinhard Meyer
2011-05-31 5:03 ` Graeme Russ
2011-05-31 5:16 ` Reinhard Meyer [this message]
2011-05-31 6:03 ` Wolfgang Denk
2011-05-31 6:23 ` Graeme Russ
2011-05-31 5:18 ` Wolfgang Denk
2011-05-31 5:37 ` Reinhard Meyer
2011-05-31 6:10 ` Wolfgang Denk
2011-05-31 4:56 ` Simon Glass
2011-05-31 5:49 ` Wolfgang Denk
2011-05-31 6:28 ` Graeme Russ
2011-05-31 6:29 ` Graeme Russ
2011-06-15 13:17 ` Graeme Russ
2011-06-15 16:03 ` Simon Glass
2011-06-15 20:38 ` Graeme Russ
2011-06-15 21:58 ` Simon Glass
2011-06-15 23:09 ` Graeme Russ
2011-06-16 5:53 ` Simon Glass
2011-06-16 6:27 ` Graeme Russ
2011-06-16 13:58 ` Simon Glass
2011-05-27 11:26 ` Wolfgang Denk
2011-05-27 14:23 ` J. William Campbell
2011-05-28 5:53 ` Graeme Russ
2011-05-28 6:18 ` Reinhard Meyer
2011-05-28 8:59 ` Graeme Russ
2011-05-29 1:41 ` J. William Campbell
2011-05-26 17:49 ` Wolfgang Denk
2011-05-26 22:51 ` Graeme Russ
2011-05-27 7:17 ` Wolfgang Denk
2011-05-27 7:33 ` Graeme Russ
2011-05-27 7:45 ` Wolfgang Denk
2011-05-27 14:58 ` Simon Glass
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=4DE47993.2020104@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