Process concurrency in perl.

Corey Edwards tensai at zmonkey.org
Fri Mar 9 11:21:26 MST 2007


On Fri, 2007-03-09 at 09:19 -0800, Michael Brailsford wrote:
> I realized fairly quickly that I could write a few simple lockfiles
> and get some concurrency with several different invocations of the
> script each generating docs and skipping over those projects which
> have already been built by the other processes.  I started 5 or 6 of
> these and started to get deadlock, surprise I know.  Is there some
> better way in perl to coordinate N processes?  I know I can use
> semaphores, but I wanted to see if there was some better "perl way" of
> doing it first, before figuring out how to do semaphores in perl.

What comes to mind is having one parent process which is in charge of
checking out the projects. It reads requests from a named pipe which all
of the child processes open and write requests to. Since the parent
would be a single thread and reading from the named pipe is a blocking
call, seems like a good way to synchronize the children.

Of course, the details are left up to you. :)

Corey





More information about the PLUG mailing list