Re: fork():Passing complex data structures between parent and child



On Wed, 18 Oct 2006 04:04:07 -0700, neok wrote:

Hi,

I am trying to implement fork() for the first time in an application
with a large number of structures holding a lot of input data and
calculated data. To speed up calculations on a multiprocessor
machine, I would like to pass on input data to child processes and
receive calculated data for further processing (graphical display) by
the parent. (You can see this app. "xnec2c" at
http://5b4az.chronos.org.uk/pages/nec2.html).

All input/calculated data are stored in malloc'ed buffers whose
pointers are members of various structures, about a dozen of
those, containing several buffer pointers each. I am new to
forking and IPC so this task seems rather daunting to me, whether
I use pipes or shared memory.

Please, is there a nice smart way to exchange data organized in
such a complex way? I would be very greateful for any info or hints.

My thanks in advance!

Regards


Neoklis

`fork' is copy-on-write which means that forked threads does not share
memory. `fork' is however implemented using `clone'. From `man 2 clone':

"Unlike fork(2), these calls allow the child process to share parts of
its execution context with the calling process, such as the memory space,
the table of file descriptors, and the table of signal handlers."

I usually prefer using POSIX-threads. Check `man 3 pthread_create'.

--
Lars Rune Nøstdal
http://lars.nostdal.org/

.



Relevant Pages

  • A newbie question re: Forms - Input and Output from an Excel Worksheet
    ... I need to use a simple form to input data. ... Calculations: ... Information required as output on Form: Lease Cost ... that is not covered by Protect Sheet or Protect Workbook. ...
    (microsoft.public.excel.programming)
  • Re: speed up calculation suggestions
    ... We use Fortran for some or our calculations and are being hampered ... Get an updated compiler ... Do you need to process all of the input data? ...
    (comp.lang.fortran)
  • validating input in textbox
    ... input data from the user ... help file in which additional dat is stored, needed for the calculations ... one page i put an excel sheet where the user can input a database of persons ... Private Sub OnlyNumbers() ...
    (microsoft.public.excel.programming)
  • Re: calling functions from a script m.file
    ... I've got a similar situation where I have an m-file which performs ... some calculations based on multiple inputs. ... If I want to repeat the calculations for 10 sets of 3 numbers, ... to use that function on a multiple set of input data so I want to ...
    (comp.soft-sys.matlab)