Subject: Re: getrusage() problem in hp300 port??
To: None <Havard.Eidnes@runit.sintef.no>
From: Greg Oster <oster@cs.usask.ca>
List: port-hp300
Date: 11/20/1997 09:11:19
Havard.Eidnes@runit.sintef.no writes:
> Hi again,
> 
> after some casual testing it appears that the the getrusage()
> problem demonstrated by the program Greg sent is machine-
> independent; I sometimes see the same behaviour on my i386/1.3_ALPHA
> P120 system (I also sometimes also see 0+0 being printed for all the
> samples of a given run...). 

On a P200 (and a P90) I've seen the 0+0, but never the "erratic" sequence.
(The P90 typically only gets 2 or 3 0+0's before a 0+some_other_number)

> I remember one of my friends making
> some comments about this problem earlier, and I'll discuss it with
> him when I get hold of him.

If it's machine independent, then perhaps that's why the following:
--------8<--------
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
main()
{
        struct timeval thetime;
        int i,j;

        for(i=0;i<10;i++) {
                gettimeofday(&thetime,NULL);
                printf( "%ld + %ld\n", thetime.tv_sec, thetime.tv_usec);
                sleep( 2 );
        }
}
--------8<--------
produces stuff like:
880037452 + 210770
880037454 + 210040
880037456 + 210040
880037458 + 210035
880037460 + 210034
880037462 + 210035
880037464 + 210035
880037466 + 210038
880037468 + 210043
880037470 + 210035

on a P200 running 1.2G.  (I though sleep() guaranteed the *minimum* time it 
would sleep (2 seconds, in this case) but the numbers above don't  support 
that...  The hp300 (040) gives:
880011060 + 928992
880011062 + 927956
880011064 + 927784
880011066 + 927780
880011068 + 927788
880011070 + 927788
880011072 + 927824
880011074 + 927784
880011076 + 927792
880011078 + 927788

which seems "wrong" for a value that should always be going up...  The Sun 
3/50 reported: 
879999369 + 10001
879999371 + 40002
879999373 + 50002
879999375 + 60002
879999377 + 70002
879999379 + 80002
879999381 + 90002
879999383 + 100002
879999385 + 110002
879999387 + 120002

(Curiously, the same program on a Dec Alpha running DU4.0 gives:
880037909 + 447254
880037911 + 449206
880037913 + 449196
880037915 + 449196
880037917 + 449187
880037919 + 449187
880037921 + 449178
880037923 + 449178
880037925 + 449169
880037927 + 449169

and a certain OS with a penguin mascot on a PPro200 gives:

880037771 + 64140
880037773 + 56251
880037775 + 56226
880037777 + 56207
880037779 + 56195
880037781 + 56190
880037783 + 56181
880037785 + 56221
880037787 + 56194
880037789 + 56199

so we're not the only OS with this anomaly...)

Later...

Greg Oster

oster@cs.usask.ca
Department of Computer Science
University of Saskatchewan, Saskatoon, Saskatchewan, CANADA