Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title Same address space for shared memory between 2 or more processes.
Ref. No. QNX.000010124
Category(ies) Development
Issue Is there a way to make a shared memory area that can share the same address space between 2 or more processes?
Solution Yes, however it is not recommended due to the problems that may occur by using this method.

The -@ option can be used to specify that the base address of the program be moved to a higher address, leaving room in low address space for the shared memory to be mapped in at the same address in all the programs.  This requires specifing the appropriate options to mmap().  If this route is taken then ordinary pointers can be used.  However this can be a dangerous method, as shared libraries (e.g. Photon, TCP/IP, X...) under QNX4 are implemented this way, and if these libaries are used, then the code will have to be mindfull for the offsets that the (Photon, TCP/IP and X) libs are using.  One other thing to be mindfull of when using the -@ option, is that there needs to be enough allowed space for the zero-page, the stack-guard page, and the maximum stack size that is specified in the program.  Once again this is not a recommended method.