shared memory & 2 Processes

Hello,

I think this is the question I want to ask.
How do you make a shared memory area that
shares the address space? I saw somewhere you
do a cc -@value + stack … Does anyone have
any examples of this?

Thanks.
Tom.

Do you mean, how do you get a shared memory area
that is shared in the same place? There is
a parameter to mmap() that will force a specific
location for the memory. There are some limitations
on where you can put things of course.



Previously, tomf4 wrote in qdn.public.qnx4:

Hello,

I think this is the question I want to ask.
How do you make a shared memory area that
shares the address space? I saw somewhere you
do a cc -@value + stack … Does anyone have
any examples of this?

Thanks.
Tom.

\


Mitchell Schoenbrun --------- maschoen@pobox.com

tomf4 <tomf4@uniserve.com> wrote:

Hello,

I think this is the question I want to ask.
How do you make a shared memory area that
shares the address space? I saw somewhere you
do a cc -@value + stack … Does anyone have
any examples of this?

It can be done – but is not recommended. I’ve talked a bit about
it in a previous response to you.

The map of a QNX4 process looks something like:

|zero page|stack|code|data|heap…

If you use the -@ option you are specifying the address to put the
bottom of the code segment at. This may conflict with shared libraries
that do the same thing. Also, this will probably prevent you from being
able to use the _CA_PCI* functions for detecting & configuring PCI bus
cards.

mmap() has to be passed the address you want the memory placed at in
the first (addr) parameter, and the MAP_FIXED flag in the flags field.

-David

David,

So where should someone put their shared memory if they
want it in a fixed location, and what does the -@ option
have to do with it. Is this to move the code up so that
there is a reliable place to put the shared memory above the
stack?




Previously, David Gibbs wrote in qdn.public.qnx4:

tomf4 <> tomf4@uniserve.com> > wrote:
Hello,

I think this is the question I want to ask.
How do you make a shared memory area that
shares the address space? I saw somewhere you
do a cc -@value + stack … Does anyone have
any examples of this?

It can be done – but is not recommended. I’ve talked a bit about
it in a previous response to you.

The map of a QNX4 process looks something like:

|zero page|stack|code|data|heap…

If you use the -@ option you are specifying the address to put the
bottom of the code segment at. This may conflict with shared libraries
that do the same thing. Also, this will probably prevent you from being
able to use the _CA_PCI* functions for detecting & configuring PCI bus
cards.

mmap() has to be passed the address you want the memory placed at in
the first (addr) parameter, and the MAP_FIXED flag in the flags field.

-David


Mitchell Schoenbrun --------- maschoen@pobox.com

Mitchell Schoenbrun <maschoen@pobox.com> wrote:

David,

So where should someone put their shared memory if they
want it in a fixed location, and what does the -@ option
have to do with it. Is this to move the code up so that
there is a reliable place to put the shared memory above the
stack?

Low address is the only safe space – just if you are using
shared libraries, make sure you don’t conflict with them.

-@ moves the code up, and the stack moves up with it. Map of
process ends up like:

|zero page|open space|stack|code|data|heap…

Shared libraries essentially do the exact same things – they move
the code (&stack) up, then map the library in at a known, fixed, low
address.

The QWindows shared library lives at 0x1000, and reserves a size
of size 0x40000. If you aren’t using that library yourself, that
range is probably safe to use. I know that none of the other libraries
overlap with it – but I don’t know what ranges the other libraries
use.

Note that if you are using other libraries, be careful at compile
time – I’m not sure if the -@ option will override the work that
cc does to figure out where it needs to put the start of code to
make room for shared libraries.

-David

Previously, David Gibbs wrote in qdn.public.qnx4:
tomf4 <> tomf4@uniserve.com> > wrote:
Hello,

I think this is the question I want to ask.
How do you make a shared memory area that
shares the address space? I saw somewhere you
do a cc -@value + stack … Does anyone have
any examples of this?

It can be done – but is not recommended. I’ve talked a bit about
it in a previous response to you.

The map of a QNX4 process looks something like:

|zero page|stack|code|data|heap…

If you use the -@ option you are specifying the address to put the
bottom of the code segment at. This may conflict with shared libraries
that do the same thing. Also, this will probably prevent you from being
able to use the _CA_PCI* functions for detecting & configuring PCI bus
cards.

mmap() has to be passed the address you want the memory placed at in
the first (addr) parameter, and the MAP_FIXED flag in the flags field.

-David

\

Mitchell Schoenbrun --------- > maschoen@pobox.com