[Trilug-ontopic] perl and threads

Michael Peters mpeters at plusthree.com
Fri Mar 11 12:11:34 EST 2011

On 03/11/2011 10:00 AM, Brian Weaver wrote:

> I don't know about using threads, but if you want multiple instances with each working on a single device then why not use a master-child process model? Have the master fork off N children and maintain a link using anonymous pipes, unix sockets, or some other IPC mechanism. The master can inform each child on what system to query and then receive a status back from the child when it's done.

I agree that you should use processes instead of threads. Threads are ok 
in Perl but processes are better and since processes are COW in Linux 
you end up having about the same amount of overhead.

But instead of writing your own from scratch, I'd look to CPAN (Perl's 
biggest weapon) to find something to handle all of the gory bits for 
you. I like Parallel::ForkManager

Michael Peters
Plus Three, LP

More information about the Trilug-ontopic mailing list