Anonymous shared objects

QNX SDP8.0Programmer's GuideDeveloper

Using an anonymous shared object eliminates the need for a publically visible name.

Traditionally, a shared memory object has a name, and QNX OS shows those names under /dev/shmem. As a QNX OS extension to POSIX, you can create an anonymous shared memory object. This has several advantages:

  • There's no need for you to create a unique name for the object that no other process is using.
  • There's no need to expose the name under /dev/shmem.
  • It avoids costly path resolution.
  • There are no race conditions, as there could be if two processes are opening the object at the same time.
  • It's useful when a process wants to create a local object and share it with spawned processes; the child processes can simply inherit the parent's file descriptor for the object.
To create an anonymous shared memory object, specify SHM_ANON for the object's name when you call shm_open(). For example:
int fd = shm_open(SHM_ANON, O_RDWR, 0600);

How do you share an object that doesn't have a name? You use a shared memory handle.

Page updated: