Determining physical address of shared memory

I currently have an application that spawns off a process and that process
spawns off another process. All three of these processes use one common
piece of shared memory to communicate. However, it appears that not all
three are using this shared memory.

Question 1: I have the virtual memory address that each of the three are
getting from creating their respective shared memory. Is there any way to
get the address of the physical memory that this virtual memory maps into?

Question 2: Are there any timing issues? If I write to the shared memory in
the first process then have another process start to read/write from that,
will it screw anything up?

Thanks in advance.
Chris.

Is your pointer to this shared memory declared as “volatile”?

If not, the compiler will ‘think’ it can cache some of the data from that
shared region.

“Chris Haidvogel” <cph@videk.com> wrote in message
news:ac0n0p$dut$1@inn.qnx.com

I currently have an application that spawns off a process and that process
spawns off another process. All three of these processes use one common
piece of shared memory to communicate. However, it appears that not all
three are using this shared memory.

Question 1: I have the virtual memory address that each of the three are
getting from creating their respective shared memory. Is there any way to
get the address of the physical memory that this virtual memory maps into?

Question 2: Are there any timing issues? If I write to the shared memory
in
the first process then have another process start to read/write from that,
will it screw anything up?

Thanks in advance.
Chris.

“Chris Haidvogel” <cph@videk.com> wrote in message
news:ac0n0p$dut$1@inn.qnx.com

I currently have an application that spawns off a process and that process
spawns off another process. All three of these processes use one common
piece of shared memory to communicate. However, it appears that not all
three are using this shared memory.

Could you perhaps post some code snippets of how you’re declaring and
initializing the memory?


Question 1: I have the virtual memory address that each of the three are
getting from creating their respective shared memory. Is there any way to
get the address of the physical memory that this virtual memory maps into?

This can be done when you mmap it. See the flags at
http://qdn.qnx.com/support/docs/neutrino/lib_ref/m/mmap.html

Question 2: Are there any timing issues? If I write to the shared memory
in
the first process then have another process start to read/write from that,
will it screw anything up?

Absolutely. You can make no determination about the order of reads and
writes to the shared memory by different processes without using some form
of synchronization such as semaphores or mutexes. Another possibility that
fits well with the QNX programming model is to have the processes send
messages to eachother to let them know when it’s okay to read and write.

If the processes are just using the shared memory for messaging each other,
you might want to use a send/recieve/reply model for communication. Another
possibility which is easier to synchronize is message queues.

cheers,

Kris

Thanks in advance.
Chris.

Problem solved.
This was a stupid error. When each process created its pointer to the
shared memory it would memset it to make sure it was empty. Well, I think
it is obvious now that if one would clear the memory and then write to it
and then the next process that got created would do the same thing so it
would appear that no one was saying anything to anyone. On my development
machine (1Ghz PIII) the loading up sequence of the processes was ok. On the
target machine (450mhz PII) the timing was WAY off and it appeared to break
the code. Stupid mistiake on my part.

Chris.

“Kris Warkentin” <kewarken@qnx.com> wrote in message
news:ac0u60$2a0$1@nntp.qnx.com

“Chris Haidvogel” <> cph@videk.com> > wrote in message
news:ac0n0p$dut$> 1@inn.qnx.com> …
I currently have an application that spawns off a process and that
process
spawns off another process. All three of these processes use one common
piece of shared memory to communicate. However, it appears that not all
three are using this shared memory.

Could you perhaps post some code snippets of how you’re declaring and
initializing the memory?


Question 1: I have the virtual memory address that each of the three are
getting from creating their respective shared memory. Is there any way
to
get the address of the physical memory that this virtual memory maps
into?

This can be done when you mmap it. See the flags at
http://qdn.qnx.com/support/docs/neutrino/lib_ref/m/mmap.html

Question 2: Are there any timing issues? If I write to the shared
memory
in
the first process then have another process start to read/write from
that,
will it screw anything up?

Absolutely. You can make no determination about the order of reads and
writes to the shared memory by different processes without using some form
of synchronization such as semaphores or mutexes. Another possibility
that
fits well with the QNX programming model is to have the processes send
messages to eachother to let them know when it’s okay to read and write.

If the processes are just using the shared memory for messaging each
other,
you might want to use a send/recieve/reply model for communication.
Another
possibility which is easier to synchronize is message queues.

cheers,

Kris

Thanks in advance.
Chris.