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

Simon Kirby (sim@netnation.com)
Sun, 8 Nov 1998 10:29:28 -0800 (PST)


On Tue, 3 Nov 1998, Hans Eric =?ISO-8859-1?Q?Sandstr=F6m ?= wrote:

> 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.

Are you running X? Chances are your machine did not hang, but you reached
a limit of processes, fork() returned -1, and then the kill loop you
sent SIGKILL to everything (-1), which would zap X without giving it a
chance to reinitialize text mode.

Either way, the probgram is still flawed as a benchmark of any sorts as
Linux could allow the process to run to the point where it calls sleep()
as soon as it forks where FreeBSD may just continue to let the parent
execute and kill the children (which is obviously going to make the
program exit faster).

Simon-

| Simon Kirby | Systems Administration |
| mailto:sim@netnation.com | NetNation Communications |
| http://www.netnation.com/ | Tech: (604) 684-6892 |

---
> 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/
> 

- 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/