QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
Creating String objects in shared memory |
Ref. No. |
QNX.000009416 |
Category(ies) |
Development |
Issue |
In QNX4, using Watcom 10.6 C++ is there a way to create String objects in shared memory? We are having problems because the String class uses a pointer to a char array in memory, and the array is not placed in the shared memory space. We need the actual characters in the string to be placed in the memory space. We are currently copying a structure which contains multiple Strings into the shared memory space. Is there a way to tell the String class where to allocate the char array?
|
Solution |
You can make it so the shared memory is at the same address in both processes by leaving space for it at compile time. To do this, use the undocumented -@ option on cc, the value passed after the @ gives the offset of the code segment.
i.e. cc -@ value prog.c
value = 8K + (Shared memory size) + (Shared libs) + (Stack Size)
The 8K is the 0 page and Stack Guard Shared memory size is your space, remember 4K pages Shared Libs, probably no Stack Size, check the default.
Then you can mmap() at address 4096, right after the 0 page. |
|