Re: fork():Passing complex data structures between parent and child
- From: Lars Rune Nøstdal <larsnostdal@xxxxxxxxx>
- Date: Wed, 18 Oct 2006 13:32:24 +0200
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/
.
- Prev by Date: Re: Cleaning up files after fork()
- Next by Date: UTF-8 encoding problem
- Previous by thread: Re: fork():Passing complex data structures between parent and child
- Next by thread: UTF-8 encoding problem
- Index(es):
Relevant Pages
|