nickswanjan has asked for the wisdom of the Perl Monks concerning the following question:

I wrote a Perl script that runs on a multiprocessor Linux server running a smp kernel, it launches several processes, and controls them by communicating via the file handles returned by $pid = open2(\*RDRFH, \*WTRFH, 'some cmd and args'); The startup and communications are all working fine, but my Linux server has 4 CPUs, and all of the processes I am starting with open2 are ending up on the same CPU, so that CPU goes to 100% while the others are not used at all. How do I get the multiple processes I am open2-ing with this script to share all of the available CPU resources?
  • Comment on IPC::Open2 multiple processes are all on the same CPU?

Replies are listed 'Best First'.
Re: IPC::Open2 multiple processes are all on the same CPU?
by cephas (Pilgrim) on Oct 12, 2006 at 18:45 UTC
    Which kernel?

    How is your script being executed?

      RHEL3, 2.4.21-40.ELsmp Perl v5.8.0 built for i386-linux-thread-multi I am executing the script from the shell, ./test.pl
        Strange. 2.4 kernels usually were notorious for bouncing processes from processor to processor, not keeping them stuck on one. You may want to try to check one of the kernel groups. Make sure to let them know exactly what kernel, and if there are 4 separate processors, or if it is hyperthreading (it is my understanding that multicore processors are treated slightly different, even though they'll show up as multiple logical processors in user space).

        If you want to get really hardcore you can set the processor affinity for those processes, letting them know which processor to run on. While that is normally 2.6 functionality, I believe it was backported into some of the Redhat kernels.

        I'd like to hear the final outcome of your investigations.