in reply to Re^3: Fork vs pThreads
in thread Fork vs pThreads

Sorry, I'm new to this. I don't understand why 50 tasks concurrently will take longer than running packs of 4.

Replies are listed 'Best First'.
Re^5: Fork vs pThreads
by BrowserUk (Patriarch) on Oct 21, 2013 at 15:15 UTC

    Change your code to:

    my $pm = Parallel::ForkManager->new(4); my $i = 0; while(i<50){ $pm->start and next; processStream($stream); $i++; $pm->finish; # do the exit in the child process } $pm->wait_all_children();

    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.
      Thank you for spending time with me :).
Re^5: Fork vs pThreads
by choroba (Cardinal) on Oct 21, 2013 at 13:47 UTC
    No packs. Just run 4 tasks, if one ends, start another one.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      How do I run those tasks? I fork 4 separately? Could you give me an example?