On Thu, 2006-10-19 at 12:25 -0600, Jacob Fugal wrote:
> On 10/19/06, Steve <[EMAIL PROTECTED]> wrote:
> > So what's the total number assuming infinite "allowed" processes, that
> > this stinker managed to spawn?
>
> 2^10
>
> I don't think the post-increment matters. The first child will still
> only spawn nine others. Example with i = 3:
>
> #include <stdio.h>
> int main (int argc, char *argv[])
> {
> int x;
> for(x=0; x<3; x++){ fork(); }
> printf("I am Spartacus!\n");
> }
>
> output:
>
> I am Spartacus!
> I am Spartacus!
> I am Spartacus!
> I am Spartacus!
> I am Spartacus!
> I am Spartacus!
> I am Spartacus!
> I am Spartacus!
>
> In every iteration, each process forks. So the number of processes
> doubles each iteration. 3 iterations, 2^3=8 processes.
I took the risk and ran your simple test. Indeed, running the loop out
to 10 results in 1024 processes. My machine actually handled it fairly
well. I wonder if the MPI library made the process a lot more
heavyweight.
$ time ./fork 10 |wc -l
1024
real 0m0.311s
user 0m0.000s
sys 0m0.012s
Corey
signature.asc
Description: This is a digitally signed message part
/* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
