Matthias Lang <>
Wed Jan 8 16:26:05 CET 2003

This patch has a couple of problems.

Firstly, it breaks the existing code. Example: this line (in the same
function as the code the patch changes):

    current_correction = ((ct_diff - tv_diff) / TICK_MS) * TICK_MS; /* trunc */

does not work if TICK_MS is floating point. With floating point, it
won't truncate the value as advertised. With integer arithmetic it

Secondly, it introduces more floating point code into areas of Erlang
which aren't directly related to floating point. For desktop PCs, this
isn't a problem since they all have CPUs with hardware floating point
support. But most embedded CPUs don't have that, so at best it's a
performance hit (if the OS has floating point emulation) and at worst
it causes a crash (I think this is the case for VxWorks).

Aside: a quick grep of the sources showed that the GC and memory
       allocation code has floating point code in it now. What do
       the VxWorks users do? Are there any left?


Vladimir Sekissov writes:
 > Good day,
 > This simple patch is intended to new Linux kernels (2.5.*) where
 > sysconf(_SC_CLK_TCK) == 1024
 > but some code in `erts/emulator/beam/erl_time_sup.c' were written with
 > assumption that this value is far less than 1000(it is traditionally
 > 100 on most systems).
 > Best regards,
 > Vladimir Sekissov
 > --- erts/emulator/beam/erl_time_sup.c.orig	2003-01-04 22:30:47.000000000 +0500
 > +++ erts/emulator/beam/erl_time_sup.c	2003-01-04 22:27:00.000000000 +0500
 > @@ -219,7 +219,7 @@
 >      Milli act_correction; /* long showed to be too small */
 >      Milli max_adjust;
 > -#define TICK_MS (1000 / SYS_CLK_TCK)
 > +#define TICK_MS (1000.0 / SYS_CLK_TCK)
 >      current_ct = KERNEL_TICKS();
 >      sys_gettimeofday(&current_tv);

More information about the erlang-questions mailing list