QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
Accessing a linked list in multiple processes |
Ref. No. |
QNX.000010189 |
Category(ies) |
Development |
Issue |
There are two different processes (I & II) that are accessing the same data structure through memory mapping. The functions shm_open & mmap are used to allocate the memory for the structure. But the structure has a large number of linked lists that are allocated in one of the processes (I). How can complete access to the data structure be given to the other process (II) that didn't allocate the memory for the linked list?
|
Solution |
Copy the header of the linked list into the shared memory object. Process 2 will be able to access all other members of the list because a member of that linked list contains a pointer to the next area in memory. The memory has been allocated by process 1 so process 2 should be able to access it. As a precautions some sort of synchronization (ie: Semaphores) on the list members shoutld be setup so that members of the list aren't accessed at the same time |
|