From owner-freebsd-bugs Sun Jan 28 20:10:09 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id UAA25580 for bugs-outgoing; Sun, 28 Jan 1996 20:10:09 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id UAA25567 Sun, 28 Jan 1996 20:10:03 -0800 (PST) Date: Sun, 28 Jan 1996 20:10:03 -0800 (PST) Message-Id: <199601290410.UAA25567@freefall.freebsd.org> To: freebsd-bugs Cc: From: Bruce Evans Subject: Re: kern/975: getrusage returns negative deltas Reply-To: Bruce Evans Sender: owner-bugs@FreeBSD.ORG Precedence: bulk The following reply was made to PR kern/975; it has been noted by GNATS. From: Bruce Evans To: FreeBSD-gnats-submit@FreeBSD.ORG, hsu@freefall.freebsd.org Cc: Subject: Re: kern/975: getrusage returns negative deltas Date: Mon, 29 Jan 1996 15:01:39 +1100 >Two calls to getrusage(). The second call indicates that the process has >used less time resource then the first call. This is caused by the granularity of the sampling method. E.g., if a process has been running for precisely 30000 usec and has been sampled once in user mode and once in system mode, then getrusage() reports 15000 usec in user mode and 15000 usec in system mode. 30 microseconds later, after the process has been sampled once more in system mode, getrusage will report 10010 usec in user mode and 20020 usec in system mode. The time in user mode has apparently gone backwards by 4990 usec. This affect is only noticable when the sample counts are too small to be accurate. It would be too expensive to use non-statistical sampling. The clock would have to be read for every syscall/interrupt entry and exit. The times should be fudged so that they never appear to go backwards. Bruce