in reply to Re^3: Win32 and threads;
in thread Win32 and threads;

Note: this code works fine under
v5.8.4 built for i386-freebsd-thread-multi-64int

I'm testing with
v5.8.4 built for MSWin32-x86-multi-thread - build 810 (activestate)

When I execute the following code if $thread_sleep = "50" my application
dies at threads_count == 119 religiously..

It exits with NO ERROR !!

if $thread_sleep = "3" then $thread_count reaches it's goal and exits...
I assume this is because older threads are exiting sooner

Is there a limit of threads per process under Win32 ??

Why don't I get any error ??

I'm using Windows 2000 - Build 2195 SP4 + patches

Thanks!
use strict; use warnings; use threads; my $thread_sleep = "50"; my $thread_count = "0"; for (1..5000) { threads->new(\&handle_thread,++$thread_count); } sleep 10; print "--Parent Quits --"; ###################### sub handle_thread { my $thread_count = shift; threads->self->detach; # so long parent print "You are thread number $thread_count \n"; sleep $thread_sleep; }
--jammin

Replies are listed 'Best First'.
Re^5: Win32 and threads; (#30674)
by BrowserUk (Patriarch) on Jul 11, 2004 at 20:07 UTC

    There is (currently) a limit of 120 threads per process (on win32/5.8.4/XP/my computer/11th July 2004/SE UK etc :). This is not a hard-wired limit within perl and may vary with build.

    That you are not seeing any error message suggests that your installation is not configured to report segfaults. There is an option to "Send Administrative Alert" in Control panel->System->Advanced->Startup and Recovery->Settings->System failure. At least that's where it is on XP.

    That perl is not detecting the underlying problem and reporting it's own message is a bug. I have tracked down the unchecked API call and will submit a perlbug with the information.

    However, if you can show me a useful application of using more than half a dozen or so simultaneous threads, I'll show you a better way :)

    Update: Perlbug # 30674.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

      However, if you can show me a useful application of using more than half a dozen or so simultaneous threads, I'll show you a better way :)
      I don't mean to disagree with this - in fact I think you're right, but I would be very interested to read an elaboration on this claim from you. Would you?

        The smiley was intended to defuse the statement from being taken as definitive, but in general, I'll stand by it (in the context of Perl programs using ithreads on Win32).

        But, it's difficult to elaborate upon for the general case. I've yet to see a good use of large numbers of iThreads. And I've yet to find the right way to write the type of application that might make use of large numbers of threads using perl.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon