Nitish,
Read these:
http://www.cse.psu.edu/~deh25/cmpsc473/notes/OSC/Processes/shm.html
However, be warned that:
- Concurrent accesses to shared resources must be guarded by a mutex
- You'll need to figure out whose responsibility it is to initialize the shared hash; if this requires a shared mutex, then you'll need to figure out whose responsibility it is to initialize the shared mutex,
and so on- All pointers that will be followed by both processes must point to objects located in the shared memory segment
- Not only that, but since uthash uses raw C pointers, both processes must agree on the LOCATION of the shared memory segment, e.g. by hard-coding the first argument to mmap()
This is all possible, but probably much harder than you ought to be tackling.
I've slapped together a quick(?) example using the POSIX shared-memory API; see the attached zipfile. Notice that it sets up a pthread_mutex_t to control access to the shared memory but then doesn't actually *use* that mutex, because I'm lazy. Also notice that I had to write my own memory allocator, which I did in as lazy a way as possible (e.g. SharedTable_free() is a no-op).
HTH,
Arthur