[erlang-questions] Re: how do I do the equivalent of ets:tab2list(timer_tab) for BIF timers

Per Hedeland per@REDACTED
Tue Dec 7 22:03:34 CET 2010


Matthias Lang <matthias@REDACTED> wrote:
>
>Matt> >In short: A bug in the linux kernel on Au1000 MIPS CPUs causes
>Matt> >       Erlang's timers and timeouts to go haywire, sometimes.
>Matt> >       Most likely, nobody but me is affected. Erlang is not the problem.
>
>Per> Hm, we actually recently had a report that the VM (R13B03) aborted on
>Per> startup with "Unexpected behaviour from operating system high resolution
>Per> timer" - this is from erl_time_sup.c, and (on Linux) the only reason I
>Per> can see is that clock_gettime(CLOCK_MONOTONIC) went backwards (which
>Per> should *never* happen, of course).
>
>I agree that it should never happen.
>
>In my case, the clock_gettime() timestamp temporarily jumped forwards
>by hours and then jumped backwards by about the same amount. That
>won't trigger the message you mention, the "unexpected..." message
>only pops up if the time jumps backwards further than it was when
>Erlang started.

Hm yes, I guess it's very unlikely to be the same problem - the abort
was "on startup", i.e.  within seconds of the hr_init_time setting, so
if that setting had been done while the time "was forward-jumped", the
subsequent backward-jump would trigger it, but...

The reporter can semi-reproduce it, said it happened twice in ten
startup attempts - but "never" when running under strace.

>I considered adding code to erl_time_sup.c to detect _any_ case of
>time going backwards so that it would be easier to detect similar
>problems. I decided not to because (a) I didn't want to complicate
>Erlang with code to check for buggy OS behaviour and

Agreed.

> (b) CLOCK_MONOTONIC is a linux-ism,

Well, only as far as Erlang VM usage goes - the timer is specified by
POSIX.1 and is AFAIK the closest thing to a portable way to get "always
goes forwards" time there is - except when it doesn't.:-(

See also http://www.erlang.org/cgi-bin/ezmlm-cgi/3/342 which I still
haven't done the proper git thing for - it's now working fine in R14B on
at least {Free,Net}BSD and QNX.

--Per


More information about the erlang-questions mailing list