http://qs1969.pair.com?node_id=1069465


in reply to Re^8: Threaded Code Not Faster Than Non-Threaded -- Why?
in thread Threaded Code Not Faster Than Non-Threaded -- Why?

I'd suggest trying the following modification:

my $thread_term :shared = 0; my $threads_init :shared = 0; my $file_read_sem : shared; + ### Add this ... WORKER: while ( !$thread_term && defined ( my $file = $work_queue-> +dequeue ) ) { { + ### Add this lock $file_read_sem; + ### Add this open my $fh, '<', $file or do { lock $d_counter; $d_counter++ +; next WORKER }; my $data = <$fh>; close $fh; } + ### Add this

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.