Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Jan 1996 18:44:20 -0800 (PST)
From:      Jeffrey Hsu <hsu>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/975: getrusage returns negative deltas
Message-ID:  <199601290244.SAA20763@freefall.freebsd.org>
Resent-Message-ID: <199601290250.SAA20985@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         975
>Category:       kern
>Synopsis:       getrusage returns negative deltas
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 28 18:50:01 PST 1996
>Last-Modified:
>Originator:     Jeffrey &
>Organization:
>Release:        FreeBSD 2.1-STABLE i386 and -current
>Environment:

>Description:

Two calls to getrusage().  The second call indicates that the process has
used less time resource then the first call.

>How-To-Repeat:

Run the following program a bunch of times.

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

main()
{

	struct rusage r, r2;

	getrusage(RUSAGE_SELF, &r);
	printf("user %d sec %d usec\n", r.ru_utime.tv_sec, r.ru_utime.tv_usec);
	printf("system %d sec %d usec\n", r.ru_stime.tv_sec,
			r.ru_stime.tv_usec);

	getrusage(RUSAGE_SELF, &r2);
	printf("user %d sec %d usec\n", r2.ru_utime.tv_sec,
			r2.ru_utime.tv_usec);
	printf("system %d sec %d usec\n", r2.ru_stime.tv_sec,
			r2.ru_stime.tv_usec);

	if (r2.ru_utime.tv_sec - r.ru_utime.tv_sec < 0)
	  printf("user time negative\n");
	if (r2.ru_utime.tv_usec - r.ru_utime.tv_usec < 0)
	  printf("user time negative\n");
	if (r2.ru_stime.tv_sec - r.ru_stime.tv_sec < 0)
	  printf("system time negative\n");
	if (r2.ru_stime.tv_usec - r.ru_stime.tv_usec < 0)
	  printf("system time negative\n");

}

>Fix:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601290244.SAA20763>