lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #1902] Timeouts and semaphores/mailboxes are too tight


From: Jonathan Larmour
Subject: [lwip-devel] [bug #1902] Timeouts and semaphores/mailboxes are too tightly integrated
Date: Sat, 21 Apr 2007 02:04:44 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060513 Fedora/1.0.8-1.1.fc3.1.legacy Firefox/1.0.8

Follow-up Comment #16, bug #1902 (project lwip):

I haven't looked at the patch itself yet, but a comment or two based on the
description. Rather than a single SYS_ARCH_TICKS_PER_SECOND constant , I
think it would be nice for the port to provide macro functions:

SYS_ARCH_JIFFIES_TO_MS(jiffies, ms)
and
SYS_ARCH_MS_TO_JIFFIES(ms, jiffies)

The reason is that on some systems ticks per second is irrational, and we
really don't want to do floating point calculations on those. Macros like
these give the porters the choice, in particular to deal with rounding.

If it is rational, then of course they would just be something like:
#define SYS_ARCH_JIFFIES_TO_MS(jiffies, ms) \
  (ms) = ((jiffies)/MY_OS_JIFFIES_PER_MS)
but doesn't have to be. Even better are powers of two, when a divide can be
avoided, and a shift used instead.

I think great care will be needed with wraparound, especially since these are
used with user-provided timeouts (e.g. select()) which can be long. Not so
much of a deal with 32-bit timestamps (although wraparound still needs
detecting), but it is for 16-bit timers. This could affect the porting
abstraction. For example one solution is for the porter to have a define for
the maximum value of jiffies before it wraps. You then ensure you wait in
individual timeouts in chunks of at most half that value (and do that
repeatedly to make up to the original time requested). It also affects
conversion between jiffies and ms - a 16-bit timestamp_t won't be able to
hold some of the millisecond values used with it. Maybe timers < 32-bit
should be a special case? Still something that has to be considered in the
design.

I'm slightly concerned that existing OSes will use names like timestamp_t and
timediff_t. Symbols named "*_t" are normally reserved for OSes. (e.g. see the
last line of the table on
http://www.opengroup.org/onlinepubs/007908799/xsh/compilation.html )
Usually you can get away with it, with suitably obscure terms, but
"timestamp_t" and "timediff_t" seem less easy. Perhaps just drop the _t, or
s/time/jiffy/ or prefix lwip?

I think the rename from timeouts to timers is good, personally. As are
sys_timer_create and sys_timer_remove. As of course is the whole idea of
using absolute timestamps, although I don't really see much value until
jiffies are used internally.


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?1902>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]