jay@splut.UUCP (Jay Maynard) (04/07/88)
From article <463@splut.UUCP>, by jay@splut.UUCP (Jay Maynard): > times(2) is documented to return, besides the cpu times in the structure > that is passed as its parameter, a monotonically increasing number that > is the elapsed real time in 60ths of a second since the machine was > booted. In small model, it does this just fine; in large model, it > always returns -1. (argh!!) I got a note from John Sully pointing out a small (?) error in my test code: I hadn't allocated space for timesbuf! :-( I changed the test code to do the allocation, as he suggested, and, lo and behold, it worked just fine. Sorry for the false alarm, folks...and maybe I oughtta do some more C hacking... A suggestion for future compiler or library bug reports on the net: include a short test program that demonstrates the problem. That way, someone else can duplicate it, and maybe catch stupid errors like mine. BTW, I guess someone over at Microport DOES read this group! :-) The revised program is included below. -----------8<----------cut here-----------8<------------------ #include <stdio.h> #include <sys/types.h> #include <sys/times.h> main() { long thistime, times(); int c; struct tms timesbuf; /* was *timesbuf - didn't allocate storage */ for (; c != EOF; (c = getchar())) { thistime = times(×buf); /* was times(timesbuf) */ printf(" %ld\n", thistime); } } -- Jay Maynard, EMT-P, K5ZC...>splut!< | GEnie: JAYMAYNARD CI$: 71036,1603 uucp: {uunet!nuchat,hoptoad!academ!uhnix1,{ihnp4,bellcore}!tness1}!splut!jay Never ascribe to malice that which can adequately be explained by stupidity. Pledge #29: Vote for Kent Paul Dolan and the Birthright Party in '88!