Subject: Re: sucky performance on i386/1.3I
To: None <tech-kern@netbsd.org>
From: Anders Magnusson <ragge@ludd.luth.se>
List: tech-kern
Date: 01/22/1999 22:36:01
> > 
> > Have you tried Ragge's test program?
> 
> No, I've not seen it posted. Might have been daydreaming.
> 
Ok, we'll take it again :-)
(Actually, it's not my test program, it's written by Jens Nilsson).

Note: The most interesting is that this program doesn't affect FreeBSD
or Linux machines at all...

-- Ragge

#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <err.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>


void
exitera(int i)
{
	exit(1);
}

int
main(int argc, char **argv)
{
	struct  itimerval timer;
	pid_t   pid;
	int             status;
	int             i;

	
	for (i = 0;;i++) {
		printf("forking... %d\n", i);
		if ((pid = fork()) < 0)
			errx(1, "parent: couldn't fork");
		else if (pid == 0) {
			/* child */
			signal(SIGALRM, exitera);
			timer.it_interval.tv_sec = 0;
			timer.it_interval.tv_usec = 0;
			timer.it_value.tv_sec = 0;
			timer.it_value.tv_usec = 250000;
			if (setitimer(ITIMER_REAL, &timer, NULL) < 0)
				errx(1, "child: invalid time");
			for(;;);
		}
		if (wait(&status) != pid)
			errx(1, "parent: child error");
	}

}