Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Methods for Asynchronous IPC

by Gloom (Monk)
on Feb 02, 2001 at 16:19 UTC ( #55986=note: print w/replies, xml ) Need Help??


in reply to Methods for Asynchronous IPC

It can be clever to use Light Weigth Processes ( LWP ). LWP allow you to execute child processes in the same address space than their parents.
In order to make this, you have to use the clone() syscall.
This kind of processes can be called "Threads".
By the way, I don't know how perl implements neither the use of threads ( if it does ) nor the clone syscall.

I ask the monks : did perl allow multithreaded programmation ?


Update :

There is a module called "Thread" that provide you basis functions to implement a parallel processing and shared variables management ( Semaphores... ).
Main process share global vars with the childs. Each of it can thus freely store a report, and main thread can process it. You may also use signal IPC to inform main process of its child's state.


Hope this helps ( and I'm not too boring :)

Replies are listed 'Best First'.
Re (tilly) 2: Methods for Asynchronous IPC
by tilly (Archbishop) on Feb 02, 2001 at 21:40 UTC
    Perl's threading model is unstable, differs with every major release, and Perl 6 (which is projected to be stable) will undoubtably have yet another model. In short you don't really want to use it.

    Beyond that, the clone() call is very, very much Linux specific. Nobody else does things that way, and if you wish to write portable code in C you won't either.

    Besides which, threaded code is definitely a mixed blessing. There are definitely times when multi-threading is the right thing to do. But I get very wary when I see people pulling it out as an answer everywhere. See Threads vs Forking (Java vs Perl) for further discussion on why.

    UPDATE
    Linking by ID seems to be broken at the moment. The missing thing to try for further discussion is Threads vs Forking (Java vs Perl)...

      Very interesting node.
      I see clearer now : thread is not in the "perl" spirit :)
      So I only discover perl and some old c uses reapers sometime !

      Thank's for this answer.

Re: Re: Methods for Asynchronous IPC
by arhuman (Vicar) on Feb 02, 2001 at 17:28 UTC

    As far as I know Thread support is still considered as experimental in Perl

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://55986]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2022-01-27 02:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?