Shared Memory

QNX SDP8.0Programmer's GuideDeveloper

Shared memory is an efficient way to share data among different processes.

Sharing memory is a common feature in operating systems that support separate address spaces for different processes. Uses include:

  • shared databases
  • producer-consumer buffers, where one process fills a buffer and then hands it to another process
  • interprocess synchronization, using a semaphore or mutex that's placed in shared memory

Additional use cases for a microkernel OS such as QNX OS include:

  • specialized buffer allocation
  • access to hardware

Instead of sharing memory, you could use:

  • message passing to send data from one process to another
  • resource managers to present access to hardware in a structured way
  • named semaphores to provide synchronization among processes

However, shared memory is usually more efficient, especially with large amounts of data. In addition, software that's ported from other OSs doesn't use QNX OS's message passing and frequently uses shared memory.

Shared memory objects that are populated with shm_ctl() are implicitly locked.

Page updated: