Shared Memory¶
Shared memory interfaces are only available with the NuttX kernel
build (CONFIG_BUILD_KERNEL=y
). These interfaces support user
memory regions that can be shared between multiple user processes.
The user interfaces are provided in the standard header file
include/sys/shm.h>
. All logic to support shared memory is
implemented within the NuttX kernel with the exception of two
low-level functions that are require to configure the
platform-specific MMU resources. Those interfaces are described
below:
-
int
up_shmat
(FAR uintptr_t *pages, unsigned int npages, uintptr_t vaddr)¶ Attach, i.e, map, on shared memory region to a user virtual address.
- Parameters
pages – A pointer to the first element in a array of physical address, each corresponding to one page of memory.
npages – The number of pages in the list of physical pages to be mapped.
vaddr – The virtual address corresponding to the beginning of the (contiguous) virtual address region.
- Returns
Zero (OK) is returned on success; a negated errno value is returned on failure.
-
int
up_shmdt
(uintptr_t vaddr, unsigned int npages)¶ Detach, i.e, unmap, on shared memory region from a user virtual address.
- Parameters
vaddr – The virtual address corresponding to the beginning of the (contiguous) virtual address region.
npages – T The number of pages to be unmapped.
- Returns
Zero (OK) is returned on success; a negated errno value is returned on failure.