in reply to Using Select and pipes to communicate with threads
Firstly, there is a lot of weirdness in this code.
my @ranges = ( [ 1, 100000], [1000001, 200000], [ 200001, 300000], [ 300001, 400000], [ 400001, 500000] );
The layout comment applies to the whole code.
I don't have a true multi-processor system, so I can't say whether this is faster than just running one big sequential file,
Although you start 5 threads, it never uses more than 25% of my 4-cpu system, and most of the time much less. Indeed, from what I can tell only one thread is ever actually doing anything.
And for the life of me I do not understand what you mean by "running one big sequential file"? How do you "run a file", big, sequential or otherwise.
I just compute primes in ranges in the threads, but the results are all fed directly back to the main thread, without any shared variables involved.
What makes you think that avoiding shared variables is a good thing? What advantages do you think this has over using a simple Thread::Queue?
Apart from that pipes work between threads -- which is a) obvious; b) I've demonstrated here years ago; -- this code seems to take the hard way to achieve something very simple.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using Select and pipes to communicate with threads
by zentara (Cardinal) on Sep 02, 2011 at 09:25 UTC | |
by BrowserUk (Patriarch) on Sep 02, 2011 at 10:00 UTC | |
by zentara (Cardinal) on Sep 02, 2011 at 15:10 UTC | |
by BrowserUk (Patriarch) on Sep 02, 2011 at 16:36 UTC | |
by zentara (Cardinal) on Sep 02, 2011 at 16:44 UTC | |
|