C - Data structure shared among processes
Hi.
I have a rather advanced question in Linux C programming.
I'm writing some code for a library. This library loads a data structure from disk, and I need to keep it in memory as long as there are processes using it. The library has init and uninit functions, so that could serve for reference counting, and when the last process stops using it, the library can unload the data structure from memory.
My main problem is that the library is used from various processes, and all of them must share the same copy of the data structure.
I've looked at shared memory, but I would like to re-use some implementation of the data structure (hash table), like for example the GLib one, but those allocate on the heap, and AFAIK they can't be changed to allocate in the shared memory segment.
|