*BSD News Article 61766


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!nntp.coast.net!howland.reston.ans.net!newsfeed.internetmci.com!in1.uu.net!newsgate.watson.ibm.com!watnews.watson.ibm.com!mdnews.btv.ibm.com!news
From: "Todd C. Huss" <husst@btv.ibm.com>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Possible Bug in getrusage?
Date: Mon, 19 Feb 1996 12:17:53 -0500
Organization: IBM
Lines: 37
Message-ID: <3128B0C1.41C6@btv.ibm.com>
NNTP-Posting-Host: huss.btv.ibm.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.0 (X11; I; AIX 2)

I have been working on a profiler under FreeBSD 2.1 and I'm using
getrusage and I think I've run into a bug. I haven't tried this
on other machines (perhaps it's a problem with my laptop (intel 
483/33)) but I have found that under FreeBSD 2.1 successive calls
to getrusage sometimes return smaller times than previous calls. For
example if you let the following program run:

#include <sys/types.h>
#include <sys/time.h> 
#include<sys/resource.h>

void main(void)
{
        int i;
        struct rusage temp;
        for (i=0; i < 1000000; i++) {
                getrusage(RUSAGE_SELF, &temp);
                printf("%d.%06d\n",temp.ru_utime.tv_sec, \
temp.ru_utime.tv_usec;
        }
}

which should just loop and print out the results, the times should
always be increasing. I have tried this under Irix 5.3 and Aix 3.2.5
where it works properly, however, under FreeBSD 2.1 the 
microseconds returned will sometimes be smaller than the previous
call even though the turn of a second hasn't occured yet. Has anyone
had similar problems under FreeBSD? Thanks for any help or suggestions!

							-Todd

-- 
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Todd Huss
                         e-mail: husst@btv.ibm.com
                       www: http://www.emba.uvm.edu/~huss
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~