in reply to Runing "regular" code with threaded perl

I have a shiny new desktop with two quad processors.

As others have said, you are under a misconception about threads. Just because you have 2 processors, dosn't mean that all programs will automatically be run in some sort of shared-cpu manner. For that matter, even if you "use threads" in a Perl script, your kernel may decide to run all threads with one cpu. Multi-threading as you envision it, is done in the kernel, and it takes specialized c programs to utilize it to it's full potential. Your single or multi-threaded Perl program is at the mercy of the kernel, when it runs. Google for "linux multi cpu scheduling" and "linux multi cpu scheduling Perl" and you will see what is happening. If you are not an expert programmer( as is the case with most of us), you are jumping into very deep water, and you will conclude that it isn't worth the time learning to override the kernel's design, unless you are doing some extremely intensive number crunching on a super-computer. Is saving a few milliseconds of execution time worth the many hours of learning required to force dual-cpu usage?


I'm not really a human, but I play one on earth CandyGram for Mongo
  • Comment on Re: Runing "regular" code with threaded perl

Replies are listed 'Best First'.
Re^2: Runing "regular" code with threaded perl
by kingskot (Sexton) on Jul 10, 2008 at 14:56 UTC
    On the contrary, I expected my perl scripts to run just as they did on my single-processor box on my multicore system, and that I'd have the option to add threads to them down the road if I so choose. I was confused when perl seemed to automatically be doing some kind of internal threaded, but as it turns out, it was an unrelated problem (see my post above). I'm happy to see that this works the way I would expect it to. Although I don't consider myself a programmer, I have experience writing massively parallel C code for cluster/supercomputers, so the concept of threading is not entirely foreign to me.