Subject: kern/6886: times and tms_utime/tms_stime running backward
To: None <gnats-bugs@gnats.netbsd.org>
From: None <leo@marco.de>
List: netbsd-bugs
Date: 01/27/1999 08:48:51
>Number:         6886
>Category:       kern
>Synopsis:       questionable return values from times
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 26 23:50:01 1999
>Last-Modified:
>Originator:     Matthias Pfaller
>Organization:
Matthias Pfaller                            Software Entwicklung
marco Systemanalyse und Entwicklung GmbH    Tel   +49 8131 5161-41
Hans-Böckler-Str. 2, D 85221 Dachau         Fax   +49 8131 5161-66
http://www.marco.de/                        Email leo@dachau.marco.de
>Release:        19990125
>Environment:
	
System: NetBSD lethe 1.3I NetBSD 1.3I (LETHE) #48: Tue Jan 26 19:53:40 CET 1999 leo@lethe:/usr/src/sys/arch/arm32/compile/LETHE arm32


>Description:
	When calling times, tms_utime/tms_stime seem to jump back by one
	or two ticks from time to time. I have run my test program on
	cvs.netbsd.org and on my shark. Both systems show the same behaviour.
>How-To-Repeat:
	Compile and run the following program:
		#include <stdio.h>
		#include <sys/times.h>

		int
		main(int argc, char **argv)
		{
			struct tms t1, t2;

			times(&t1);
			while (1) {
				times(&t2);
				if (t2.tms_utime < t1.tms_utime ||
				    t2.tms_stime < t1.tms_stime) {
					fprintf(stderr, "%d->%d %d->%d\n",
						t1.tms_utime, t2.tms_utime,
						t1.tms_stime, t2.tms_stime);
				}
				t1 = t2;
			}

			exit(0);
		}
	Sample output:
		0->1 2->1
		1->3 22->21
		3->4 24->22
		4->6 46->44
		6->7 56->55
		7->9 78->76
		9->9 81->80
		9->9 81->80
		9->10 101->100
		10->12 101->100
		12->13 129->128
		14->13 129->130
		14->13 131->131
>Fix:
	Don't know. Could this be a bug in microtime?
>Audit-Trail:
>Unformatted: