erlang:now() in erlang 4.9.1 on Linux

Ulf Wiger etxuwig@REDACTED
Thu Apr 20 13:24:30 CEST 2000


On Thu, 20 Apr 2000 matthias@REDACTED wrote:

>The behaviour Pekka is seeing is wrong, though I think that the
>uniqueness requirement on now() should be removed. If you want
>something unique, use make_ref(). If you want to know the time, call
>now() (or time()).

This is a tricky issue, and it's certainly compounded by the fact 
that erlang:now() *is* used both for unique IDs and for time 
representation. There are basically two reasons for this:

- make_ref() does not generate a *persistently* unique identifier.
  It is only temporarily unique (hopefully for as long as it is
  referenced.) In contrast, {node(), erlang:now()} is an example
  of a persistently unique global ID - in part due to the uniqueness
  requirement on erlang:now() (*)

- erlang:now() is currently the only way to get a timestamp with 
  sub-second accuracy in Erlang.

>I can imagine future hardware where keeping now() both unique from
>call to call AND more or less representing the time becomes difficult.

I would like to see a new function, e.g. hrtime(), in Erlang, and 
a shift in focus of erlang:now() to become a (strictly increasing)
internal real-time clock. It is vital that Erlang has a sense of 
time that keeps ticking in one distinct direction, regardless of
what the system clock says. 

/Uffe

(*) Of course, one can upset this as well by stopping the node,
setting back the time, and then restarting the node. Oh well...
-- 
Ulf Wiger, Chief Designer AXD 301         <ulf.wiger@REDACTED>
Ericsson Telecom AB                          tfn: +46  8 719 81 95
Varuvägen 9, Älvsjö                          mob: +46 70 519 81 95
S-126 25 Stockholm, Sweden                   fax: +46  8 719 43 44




More information about the erlang-questions mailing list