Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Using forks and threadsby BrowserUk (Patriarch) |
on Jul 20, 2006 at 08:49 UTC ( [id://562526]=note: print w/replies, xml ) | Need Help?? |
There is a lot of misinformation around. perlthrtut was originally written about/relating to perl5005 threads, and has barely been revised since their demise in favour of iThreads. Further, a lot of the casual advise available in reference to concurrency in Perl is dispensed by people who have made little or no attempt to utilise iThreads in any meaningful way, and is often coloured by experiences born of early 5005threading over early versions of *nix pthreads libraries, before they had figured out how to properly resolve threading and forking. Using forking and threading in the same program does complicate matters. For example, what should happen if you call fork within a process that has 3 running threads?
Under win32, calling system within a thread process is a perfectly safe thing to do as it doesn't use fork, or attempt to perform any cloning of the original process. On other systems you will need to understand the function and limitations of the underlying OS threading libraries, and their interaction with the iThread implementation on your systems. There seems to be little or no information available regarding this in conjunction with *nix systems. Basically, Perl threading has been so deamonised, that there are many areas of it's operation that have never been explored. If you are writing code for immediate production use, then you should probably avoid using a threads + fork combination as you would be trailblazing and may well encounter latent bugs and need to wait for several builds before fixes would become available. If your program is less urgent and you have the will to explore the possibilities, especially if you would then be able to pass on your experiences, it's possible that the combination could be used to good effect and could benefit the wider community. In either case, if you posted a description of the program you are going to write, and where you intend to use threads and fork, then you may well get some good advise on one or more ways of tackling the problem both with and without using threads. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|