in reply to Threads or Forking?

If you would like to share large amounts of read-only memory between the processes (read: threads or processes), then fork is your choice. Perl's ithreads implementation doesn't support truly shared memory, or COW (copy-on-write) shared memory.

On the other hand, if you want to share large amounts of read-write memory, or if you want to share objects between the processes, then there is no reasonable option that I am aware of. The best option that I've found for communicating complex data structures between processes is serializing the data and printing it over a socket or pipe. The best option for sharing objects may be SOAP, RPC::PlServer, or something similarly obnoxious (or beautiful, depending on your point of view).

I would love to learn that I am wrong about this.

-Colin.

WHITEPAGES.COM | INC

Replies are listed 'Best First'.
Re^2: Threads or Forking?
by mugwumpjism (Hermit) on Jul 29, 2005 at 00:40 UTC

    Of course databases are the "usual" way to share state between concurrent processes. All the hard problems are already solved that way...

    $h=$ENV{HOME};my@q=split/\n\n/,`cat $h/.quotes`;$s="$h/." ."signature";$t=`cat $s`;print$t,"\n",$q[rand($#q)],"\n";