[Mono-list] Environment.TickCount not as documented by MS (was: A mono bug)?

Iain McCoy iain@mccoy.id.au
Thu, 19 Feb 2004 14:10:35 +1100


On Thu, 2004-02-19 at 02:16, Lawrence Oluyede wrote:
> I've written a simple script to compute the uptime of the machine.
> It works well on MS.NET on Win2k (i tried to compare the output with 
> some other similar utilities) but on Mono 0.29 on my Gentoo box it fails 
> (the procps uptime tells me another time instead of the one that i get 
> with my uptime). Maybe I'm wrong or maybe Mono is wrong... anyway I 
> can't install Mono 0.30 cause it doesn't compile on Gentoo and on 
> Windows it doesn't run :(
> 
It seems that for Environment.TickCount mono returns basically the same
thing as it returns for DateTime.Ticks.

Environment.TickCount's icall looks like this:
        res = (gint32) gettimeofday (&tv, &tz);
                                                                                
        if (res != -1)
                res = (gint32) ((tv.tv_sec & 0xFFFFF) * 1000 +
(tv.tv_usec / 1000));
        return res;

while the DateTime_GetNow icall does this:
        if (gettimeofday (&tv, NULL) == 0) {
                res = (((gint64)tv.tv_sec + EPOCH_ADJUST)* 1000000 +
tv.tv_usec)*10;
                return res;
        }


These are rather more similar than makes sense, in any case.

Anyway, Environment.TickCount is documented by MS (at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemEnvironmentClassTickCountTopic.asp) as "containing the amount of time in milliseconds that has passed since the last time the computer was started". I think mono's implementation should probably do something similar, although I'm not yet sure what the correct way to do that something similar would be.
-- 
Iain McCoy <iain@mccoy.id.au>