access to pointer from different process

I would like to eliminate as many data moves as possible and so I would like
to allocate a structure in one process and pass the pointer to another
process. Then access that structure from the process that did not allocate
the memory. Is there a way to do this in QNX?

Jay Witherspoon <spoon@scubadiving.com> wrote:

I would like to eliminate as many data moves as possible and so I would like
to allocate a structure in one process and pass the pointer to another
process. Then access that structure from the process that did not allocate
the memory. Is there a way to do this in QNX?

Yes, you will want to setup a named shared memory area (docs on shm_*() will
help you out there). Then each process can open up the same view. You
will have to pass pointer offsets rather then pure pointers, but you can
easily wrap up the transaction to take a pointer, make an offset, pass the
offset, make a pointer.

chris


Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

Chris,

thanks for the info, can you point me the right direction on the functions
to convert pointers to offsets and back to pointers in the 2nd process?
That sounds like it is exactly what I was looking for.

“Chris McKillop” <cdm@qnx.com> wrote in message
news:bda13t$ptr$1@nntp.qnx.com

Jay Witherspoon <> spoon@scubadiving.com> > wrote:
I would like to eliminate as many data moves as possible and so I would
like
to allocate a structure in one process and pass the pointer to another
process. Then access that structure from the process that did not
allocate
the memory. Is there a way to do this in QNX?


Yes, you will want to setup a named shared memory area (docs on shm_*()
will
help you out there). Then each process can open up the same view. You
will have to pass pointer offsets rather then pure pointers, but you can
easily wrap up the transaction to take a pointer, make an offset, pass the
offset, make a pointer.

chris


Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

Jay Witherspoon <spoon@scubadiving.com> wrote:

Chris,

thanks for the info, can you point me the right direction on the functions
to convert pointers to offsets and back to pointers in the 2nd process?
That sounds like it is exactly what I was looking for.

shmem_base = mmap();
ptr = shmem_base + offset;
offset = ptr - shmem_base;

Store the offset in the shared memory area. Use the *ptr for access.

-David

“Chris McKillop” <> cdm@qnx.com> > wrote in message
news:bda13t$ptr$> 1@nntp.qnx.com> …
Jay Witherspoon <> spoon@scubadiving.com> > wrote:
I would like to eliminate as many data moves as possible and so I would
like
to allocate a structure in one process and pass the pointer to another
process. Then access that structure from the process that did not
allocate
the memory. Is there a way to do this in QNX?


Yes, you will want to setup a named shared memory area (docs on shm_*()
will
help you out there). Then each process can open up the same view. You
will have to pass pointer offsets rather then pure pointers, but you can
easily wrap up the transaction to take a pointer, make an offset, pass the
offset, make a pointer.

chris


Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/


QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

David Gibbs <dagibbs@qnx.com> wrote:

Jay Witherspoon <> spoon@scubadiving.com> > wrote:
Chris,

thanks for the info, can you point me the right direction on the functions
to convert pointers to offsets and back to pointers in the 2nd process?
That sounds like it is exactly what I was looking for.

shmem_base = mmap();
ptr = shmem_base + offset;
offset = ptr - shmem_base;

Store the offset in the shared memory area. Use the *ptr for access.

Or use message passing to pass the offset(s) around.

chris


Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

Maybe I am misunderstanding your description, but a malloc is occuring in
one process and then you are proposing I use shared memory to pass the
offset or are you saying the malloc’d memory is in the shared memory? I
guess I am confused how the pointer from the malloc relates to the shared
memory. Thanks for your help!!!

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:beevvu$mf6$1@nntp.qnx.com

Jay Witherspoon <> spoon@scubadiving.com> > wrote:
Chris,

thanks for the info, can you point me the right direction on the
functions
to convert pointers to offsets and back to pointers in the 2nd process?
That sounds like it is exactly what I was looking for.

shmem_base = mmap();
ptr = shmem_base + offset;
offset = ptr - shmem_base;

Store the offset in the shared memory area. Use the *ptr for access.

-David

“Chris McKillop” <> cdm@qnx.com> > wrote in message
news:bda13t$ptr$> 1@nntp.qnx.com> …
Jay Witherspoon <> spoon@scubadiving.com> > wrote:
I would like to eliminate as many data moves as possible and so I
would
like
to allocate a structure in one process and pass the pointer to
another
process. Then access that structure from the process that did not
allocate
the memory. Is there a way to do this in QNX?


Yes, you will want to setup a named shared memory area (docs on shm_*()
will
help you out there). Then each process can open up the same view. You
will have to pass pointer offsets rather then pure pointers, but you
can
easily wrap up the transaction to take a pointer, make an offset, pass
the
offset, make a pointer.

chris


Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I
get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/




\

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Jay Witherspoon <spoon@scubadiving.com> wrote:

Maybe I am misunderstanding your description, but a malloc is occuring in
one process and then you are proposing I use shared memory to pass the
offset or are you saying the malloc’d memory is in the shared memory? I
guess I am confused how the pointer from the malloc relates to the shared
memory. Thanks for your help!!!

You aren’t going to use malloc. You are going to want to create and map
in a shared memory object into both processes. Then you can pass around
the offset into this object. Look up the docs on shm_ family of calls for
examples of doing the object creation.

chris


Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

Jay Witherspoon <spoon@scubadiving.com> wrote:

Maybe I am misunderstanding your description, but a malloc is occuring in
one process and then you are proposing I use shared memory to pass the
offset or are you saying the malloc’d memory is in the shared memory? I
guess I am confused how the pointer from the malloc relates to the shared
memory. Thanks for your help!!!

No – don’t malloc().

If memory is to be used for communication – it must be in the
pre-setup shared memory area.

-David

“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:beevvu$mf6$> 1@nntp.qnx.com> …
Jay Witherspoon <> spoon@scubadiving.com> > wrote:
Chris,

thanks for the info, can you point me the right direction on the
functions
to convert pointers to offsets and back to pointers in the 2nd process?
That sounds like it is exactly what I was looking for.

shmem_base = mmap();
ptr = shmem_base + offset;
offset = ptr - shmem_base;

Store the offset in the shared memory area. Use the *ptr for access.

-David

“Chris McKillop” <> cdm@qnx.com> > wrote in message
news:bda13t$ptr$> 1@nntp.qnx.com> …
Jay Witherspoon <> spoon@scubadiving.com> > wrote:
I would like to eliminate as many data moves as possible and so I
would
like
to allocate a structure in one process and pass the pointer to
another
process. Then access that structure from the process that did not
allocate
the memory. Is there a way to do this in QNX?


Yes, you will want to setup a named shared memory area (docs on shm_*()
will
help you out there). Then each process can open up the same view. You
will have to pass pointer offsets rather then pure pointers, but you
can
easily wrap up the transaction to take a pointer, make an offset, pass
the
offset, make a pointer.

chris


Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I
get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/




\

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.


QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.