Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Perl

Journal jeffy124's Journal: Perl Threads Question 6

Really simple yes/no question that seems to have no easy-to-find answer:

Do threads in Perl take advantage of multiple CPUs?? It's 5.6.1 on an i386-linux.

I've done countless google searches and the like, looked through the camel book, and have had no luck. I posted this to comp.lang.perl last week and the only response I got was "upgrade to 5.8," which is not an available option.

This discussion has been archived. No new comments can be posted.

Perl Threads Question

Comments Filter:
  • unless you fork a new process or unless you are running several instances of your scripts (like in CGI), you can't take advantage of more than one cpu.

    no idea about 5.8. i only heard 5.8 is dangerous because several tiny details aren't compatible with 5.6.
    • sorry, but it does have threads, starting with 5.6.0. Camel book chapter 17.

      forking might be an option, but the script might become part of something larger, so i prefer to have a bunch of lightweight processes running around.
      • oops. sorry for the misinformation.. i've worked with perl 5.005 for a too long time (debian potato..). never used a single 5.6 feature yet.

        to test if perl threads can use multiple cpus, start a perl program with 2 threads and watch the output of ps. if the program appears twice, it can use both cpus. at least on linux this works, because linux displays threads as separated processes.
  • ... it does the fork thing. But, to help answer your question, its not the language that supports multiple processors, its the OS. If it was multi-threading, it asks the OS to do the threading, and the OS determines what goes on which processor.

    Quick note: This is from an old OS class I took in college, so my info may not be to date for the modern languages...
    • as i told the other guy, camel chapter 17.

      i realize the OS is a factor, but perl's interpreted, and nothing has explicitly said that multiple processors will be used if threads are used. For instance, Java used to support only user-threads, meaning the OS had no knowledge of threading, hence everything took place on one processor. Java now uses kernel threads, taking advantage of multiple cpu's.

      The question really boils down to "Which does perl use - user threads or kernel threads?"

"Plastic gun. Ingenious. More coffee, please." -- The Phantom comics

Working...