This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Open a typed memory object
#include <sys/mman.h> int posix_typed_mem_open( const char * name, int oflag, int tflag);
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The posix_typed_mem_open() function establishes a connection between the typed memory object specified by the name and a file descriptor. It creates an open file description that refers to the typed memory object and a file descriptor that refers to the open file description.
This function was added in the QNX Neutrino Core OS 6.3.2. |
The names of typed memory regions are derived directly from the names of the asinfo segments. The asinfo section itself describes a hierarchy, and so the naming of typed memory object is a hierarchy.
The posix_typed_mem_open() function resolves the name as follows:
For more information, see “Typed memory” in the Interprocess Communication (IPC) chapter of the System Architecture guide.
The file descriptor is used by other functions to refer to that typed memory object.
The setting of tflag affects what happens when you call mmap() with the file descriptor for the typed memory object:
The mapped area is unavailable for allocation until all processes unmap it. |
If tflag is 0 or POSIX_TYPED_MEM_MAP_ALLOCATABLE, the offset parameter to mmap() specifies the starting physical address in the typed memory region; if the typed memory region is discontiguous (multiple asinfo entries), the allowed offset values are also discontiguous and don't start at zero as they do for shared memory objects. If you specify a [paddr, paddr + size) region that falls outside the allowed addresses for the typed memory object, mmap() fails with ENXIO.
The oflag controls what permissions you're allowed to mmap() with. For example, if oflag is O_RDONLY, you can't do a mmap() with MAP_SHARED and PROT_WRITE.
If successful, posix_typed_mem_open() returns a file descriptor for the typed memory object that is the lowest numbered file descriptor not currently open for that process. The open file descriptor is new and isn't shared with any other processes. The FD_CLOEXEC file descriptor flag associated with the new file descriptor is cleared.
The mmap(), posix_mem_offset(), posix_typed_mem_get_info(), fstat(), dup(), dup2(), and close() functions can operate on a file descriptor that posix_typed_mem_open() returns.
As Neutrino extensions:
A nonnegative integer that represents the lowest-numbered unused file descriptor, or -1 if an error occurred (errno is set).
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
close(), dup(), dup2(), fstat(), ftruncate(), mmap(), msync(), posix_mem_offset(), posix_typed_mem_get_info()
“Typed memory” in the Interprocess Communication (IPC) chapter of the System Architecture guide