Hi All,
I've got a problem.
I have wrapped a C linux library using perl-xs. The library provides
- an init function (where a C struct is initialised)
- a do function (where actions are performed using the C struct)
- a free function (where the C struct is freed).
I have 30 perl slaves (processes) that each use their own instance of the C struct in memory.
The problem is that each struct requires around 30 MB (30 *30 = a lot).
Now I would normally initialise the struct in the parent perl controlling thread and pass it too each slave, however I do not have control of the parent thread (at least not withour hacking someone else's source code).
So, the question is, how can I share the initialised C struct between all threads? I've had a couple of ideas:
- write a server that maintains a pointer to the struct.
- keep the struct in a file :/ ?!
- somehow cache the struct between processes within the C side of the wrapper - how could I do this?
Any ideas?
Thanks for any help on this,
rotis23