On Fri, Feb 27, 2009 at 4:50 PM, Joe Vornehm Jr. <joe.vorn...@gmail.com> wrote:
> On Fri, Feb 27, 2009 at 8:47 AM, Søren Hauberg <so...@hauberg.org> wrote:
>>
>> fre, 27 02 2009 kl. 14:03 +0100, skrev Jaroslav Hajek:
>> > in case anyone is interested, I committed today into the "general"
>> > package an initial m-file implementation of parcellfun.
>> > parcellfun is supposed to be able to evaluate a given function for
>> > multiple sets of input arguments using multiple processes.
>>
>> Just out of ignorance: doesn't this require that Octave is thread-safe?
>
> No, since fork() spawns a separate process, and communication is done via
> pipes.  Threads within the same process have access to (and can trample)
> each other's resources; hence the need for being "thread-safe."  Processes
> do not have access to each other's resources.  The one exception is that a
> forked process has access to its parent's open filehandles, including pipe
> handles. But if the parent and child used the pipe incorrectly, they just
> wouldn't communicate; they would not, for instance, ruin each other's data
> like threads could do.  In fact, the operating system won't even let them
> directly access each other's data.
>
> I hope my explanation sums it up well.  If you're new to the idea and want
> to learn more, you could Google "process vs. thread" or "fork vs. thread" or
> something similar.
>
> Joe V.
>

Well, Joe explained it all nicely. I'd just add that Linux implements
fork () efficiently using copy-on-write pages, thus eliminating the
need to duplicate all process memory (only the pages that are written
to). This makes such an approach fairly efficient, though threads are
still better. The nice aspect is that you don't need thread-safety;
OTOH, you need IPC mechanism such as pipes.
On Windows, it is known that multi-processing is much less efficient
than multi-threading, though I didn't know it was a "disaster" (as
Marco noted).



-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to