On Thu, 2006-10-19 at 05:40 -0600, Steve wrote:
>     for(x = 0; x < 10; x++){
>       if(fork() > 0){
>               MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /* Get my rank          
> */
>               MPI_Comm_size(MPI_COMM_WORLD, &size);   /* Get the total number 
> of
> processors */
>               printf("Processor %d of %d: Running!\n", myrank, size);
>       }
>     }
> 
> This code looks harmless at first glance, but turns out it is idiotic,
> however it took me a full on hour to figure out why.
> Anyone wanna guess whats wrong?

I guess you forked off 10! (3,628,800) processes. We like to call that a
fork bomb.

Let's see. You could probably do this:

        int x, parent = 1;
        for (x = 0; x < 10; x++){
          if (parent && !fork()){
              parent = 0;
              MPI_stuff();
            }
          }
        }

Corey

Attachment: 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.
*/

Reply via email to