XP is just a number | |
PerlMonks |
Re: Score: Perl 1, Ruby 0by BrowserUk (Patriarch) |
on Feb 21, 2006 at 07:33 UTC ( [id://531636]=note: print w/replies, xml ) | Need Help?? |
As pointed out, Ruby's threads aren't kernel threads. The scheduling is done by Ruby itself which means that individual opcodes aren't preempted. As backticks are a single opcode, regardless of what you put in them, the opcode won't return, and therefore can't be preempted until the command has finished. However, you can avoid that by using IO.popen and reading the commands output 1 line at a time
That said, you don't appear to be using the output from the backticks, so you probably shouldn't be using them anyway. As with Perl's threads, you gotta learn to use'em right :) The nice thing about Ruby's threads is that they are very light. When playing with them a while ago I modified the simple example from the Ruby book and started 100,000 of them concurrently and it only required 130 MB. With Perl's threads you'll be limited to *Update:The limit used to be the same as the pseudo-processes limit, which is still 64, but the threads limit (as of 5.8.6) has been raised to 120. This discovered via the use of the following snippet:
Which produces
Update2: Having given up trying to unwind the multitude of defines equivalences that surround PERL_GET_CONTEXT (and the associated mess that is the whole aTHX pTHX pTHX_ thing), I gave up and took a different tack, that of asking the operating system what TLS indexes are being used. The upshot is that whatever the storage is that is being run out of, it isn't TLS indexes.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Meditations
|
|