lkml.org 
[lkml]   [1998]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectFreeBSD & Linux
Can somebody tell me why this program under FreeBSD works much more faster
then under Linux ?

#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);
_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);
}

FreeBSD: ./fork 100 - 20 seconds
Linux: ./fork 100 - 204 seconds on kernel 2.0.35
and 220 seconds on kernel 2.1.126

FreeBSD: AMD486-133MHz, 32Mb RAM
Linux: iP133, 32Mb RAM

P.S:
Sorry for my english.

------------------------------------------
Sher A. Pavel
e-mail: pavel@lime.hop.stu.neva.ru

Why use windows since there is a door ?
Anonym.


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

\
 
 \ /
  Last update: 2005-03-22 13:45    [W:0.098 / U:0.660 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site