Give special attributes to a shared memory object


#include <sys/mman.h>

int shm_ctl_special( int fd,
             int flags,
             uint64_t paddr,
             uint64_t size,
             unsigned special );


The file descriptor that's associated with the shared memory object, as returned by shm_open().
One or more of the following bits, defined in <sys/mman.h>:
  • SHMCTL_ANON — allocate anonymous memory.
  • SHMCTL_GLOBAL — a hint that any mapping to the object could be global across all processes.
    Note: In order to use the SHMCTL_GLOBAL flag, your process must have the PROCMGR_AID_MEM_GLOBAL ability enabled. For more information, see procmgr_ability().
  • SHMCTL_HIGHUSAGE — a hint that the object is used a lot, and so the system should try to do things to speed up access to it.
  • SHMCTL_ISADMA — memory should be suitable for ISA DMA (e.g. it should be below 16 MB, and shouldn't cross 64 KB boundaries).
  • SHMCTL_LAZY — delay allocating the memory until it's referenced.

    If you create anonymous shared memory objects (by calling mmap() with MAP_ANON | MAP_SHARED and a file descriptor of -1), a MAP_LAZY flag implicitly sets the SHMCTL_LAZY flag on the object.

  • SHMCTL_LAZYWRITE — a hint that a mapping of this object could use lazy-writing mechanisms.
  • SHMCTL_LOWERPROT — a hint that the system may map this object in such a way that it trades lower memory protection for better performance.
  • SHMCTL_NOX64K — memory shouldn't cross 64 KB boundaries.
  • SHMCTL_PHYS — use physical address, or allocate physically contiguous memory if used with SHMCTL_ANON.
    Note: In order to use the SHMCTL_PHYS flag, your process must have the PROCMGR_AID_MEM_PHYS ability enabled. For more information, see procmgr_ability().
  • SHMCTL_PRIV — a hint that a mapping of this object may require privileged access.
Note: Some of the above bits have specific meanings for different processors. For more information, see the documentation for shm_ctl().
A physical address to assign to the object, if you set SHMCTL_PHYS in flags.
The new size of the object, in bytes, regardless of the ANON/PHYS flag.
Processor-specific flags; see the following sections below:



Use the -l c option to qcc to link against this library. This library is usually included automatically.


The shm_ctl_special() function modifies the attributes of the shared memory object identified by the handle, fd. This handle is the value returned by shm_open().

The shm_ctl_special() function is similar to shm_ctl(), but has an additional processor-specific argument, special.

  • Calling shm_ctl_special() with a special argument of 0 isn't equivalent to calling shm_ctl(). There's an internal flag that tells the memory manager which function you called, so it can treat shared objects differently. Specifying 0 for special could clear some special bits that are on by default.
  • The combination SHMCTL_ANON | SHMCTL_PHYS has the same behavior as for mmap(): it indicates that you want physically contiguous RAM to be allocated for the object.
  • On ARM targets, once you've called shm_ctl() for a shared memory object, you can't resize it. You must unmap and unlink the shared object, and then recreate it.
  • If you specify SHMCTL_PHYS in the flags, then paddr and size must be even multiples of the page size (sysconf(_SC_PAGE_SIZE)).

ARM-specific flags

For ARM platforms, the special argument specifies the page table entry (PTE) bits to be set when the object is mapped. These bits and their meaning are generally processor-specific:

For ARMv4 processors (e.g. ARM926-based SoCs), you can specify the following:

For ARMv5 processors using extended small pages (e.g. xscale-based SoCs), you can specify the following:

For ARMv6 processors (e.g. ARM11-based SoCs), you can specify the following:

PPC-specific flags

These special PPC flags refer to the bits in the page table entries that map the object:

Flag Definition If the bit is 0: If the bit is 1:

(endian-ness, which is available only on some chips)

Refers to the bit ordering used to represent data. The page is accessed in big-endian byte order. Not accessed in big-endian byte order.

(guarded memory)

Prevents speculative, out of sequence accesses from being performed on a region (i.e. instruction prefetches for speculative accesses). Access to the page isn't guarded and can be done before it's known if required by sequential execution. All loads and stores to the page are performed without speculation (they are known to be required).

(cache inhibit)

Marks the page as uncacheable, meaning that the cache is always bypassed, and that all loads and stores access main memory. The page is cacheable. The page is cache-inhibited, and the data should not be cached downstream from the processor.

(memory coherence required)

Refers to system memory coherence. The transaction is ignored, meaning that memory is not coherent or that this is a transaction that doesn't need to be looked at; memory coherence is not required. Memory coherence is required.

(write through cache)

Operations update the main memory as well as the cache. The page is a write-back (for coherency) in the system, and the data must be forwarded at least one cache level toward memory. All stores performed to this page are written to main memory, meaning that the data for a write transaction is forwarded to system memory, or to a memory-mapped device.

For additional information about these bits, see a PPC architecture guide.

SH4-specific flags

On SH4 7760, the special argument controls the space attribute bits of the UTLB (see section 6.3.1 of 7760 hardware manual).


An error occurred (errno is set).


An invalid combination of flags was specified, or the shared memory object is already "special."
The calling process doesn't have the required permission; see procmgr_ability().


QNX Neutrino

Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes