Re: FreeBSD & Linux [./fork 500 totally hangs my machine 2.1.127]

Hans Eric =?ISO-8859-1?Q?Sandstr=F6m (hes@xinit.se)
Tue, 03 Nov 1998 16:05:11 +0100


Hans Eric Sandström wrote:

> Sher Pavel A. wrote:
>
> > Can somebody tell me why this program under FreeBSD works much more faster
> > then under Linux ?
> >

I did put in one sleep and tested on my macine:
./fork 100 - 1 sec
./fork 200 - 2 sec
./fork 300 - 2 sec
./fork 400 - 3 sec
./fork 500 *** My machine totally hangs.

Please Alan, Can you explain this or is this some bug in the kernel??

-- Moified fork.c program.
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>

void main(int argc, char *argv[])
{
unsigned int num, i, st;
time_t new_time, old_time;
int *pid;

if (argc < 2) {
printf("Usage: fork nnn\n");
_exit(0);
}
num=atoi(argv[1]);
pid=malloc(sizeof(int)*num);
old_time=time(NULL);
for (i=0; i<num; i++) {
st=fork();
if (st == 0) {
while (1) {
sleep(1);
printf("Process %i got one tick.\n", i);
}
_exit(0);
}
pid[i]=st;
printf("Process %i started.\n", i);
}
for (i=0; i<num; i++) {
kill(pid[i], SIGKILL);
printf("Process %i killed.\n", i);
}
new_time=time(NULL);
printf("Total time to spawn and kill %i processes : %i\n", num,
new_time-old_time);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/