in reply to Re: How do I run subroutines in parallel?
in thread How do I run subroutines in parallel?

Yes we are running this on a multiprocessor box. I understood that threads were unstable in perl. Then again we are using perl 5.003.

I need to look into fork tomorrow. This might be what I need. How do I call the subroutine? Do I need to split the subroutine into it's own perl file and call: fork(perl subroutine.pl)

Also, I need to save the stdout/stderr. If I run things in parallel I think the output will be "mixed up". Correct?

Sorry for such dumb questions...I'm not fluent in perl. :) I've rarely ever used modules... and I've never used threads in perl. And I can't find code examples to do this.

Thanks for all the help!
  • Comment on Re: Re: How do I run subroutines in parallel?

Replies are listed 'Best First'.
Re: Re: Re: How do I run subroutines in parallel?
by Jeppe (Monk) on Sep 10, 2002 at 16:45 UTC
    If I run things in parallel I think the output will be "mixed up". Correct?Yes and no. You may redirect the output into different files.

    You may also use file locking to make sure that the messages are written to a file in a certain order.

    There are other issues that you have not considered. Once you fork, any contact between parent and child will need to use some IPC (InterProcess Communication) method in order to give data to a child, and to retrieve it. These include TCP Sockets, UNIX Sockets, shared memory & semaphores, RDBMS and finally simple files. I wish you good luck in your fight against the daemons of deadlock and concurrency.