HANDLE osOpenSharedMemory( SYSNAME Name, PVOID *Address );
The unique name assigned to the shared memory object to be opened.
A pointer to a variable that receives the base address of the existing shared memory buffer (may be NULL if the address is retrieved later via other functions).
Returns a valid handle to the opened shared memory object upon success, or NULL_HANDLE if the operation fails. Call the osGetLastError function to retrieve extended error information.
This function opens an existing named shared memory object, allowing the calling task to access a pre-allocated memory region shared with other tasks.
Shared memory objects provide mechanisms for creating and managing access to a memory space that is utilized concurrently by multiple tasks within the system.
When a shared memory object is created, an optional name can be assigned to it. This name serves as the identifier for other tasks to gain access to the same memory region via the osOpenSharedMemory function. Once a task has completed its operations with the shared memory, it must release its handle using osCloseHandle. The kernel only destroys the underlying memory and the object itself after every task that opened it has closed its respective handle. For more detailed information, refer to the System Objects Management section.
To minimize the footprint of the output code, the system excludes name management logic if no osOpen* functions are called by the application. In this scenario, object names are ignored during creation. See the System Objects Management section for further details on memory optimization and object naming.
The memory buffer associated with the handle is allocated during the initial call to osCreateSharedMemory. When opening the object, the base address of this pre-existing buffer is written to the location provided by the Address parameter.
For additional architectural details and synchronization methods, please refer to the Shared Memory section.
This function is available only when both the OS_USE_SHARED_MEM and OS_OPEN_SH_MEM_FUNC configuration constants are set to 1. If the function is not required, setting OS_OPEN_SH_MEM_FUNC to 0 will reduce the final size of the executable.
| Version: | 1.0 |
|---|---|
| Header file: | OS_SharedMem.h (include OS_API.h) |
| See also: | HANDLE, NULL, NULL_HANDLE, OS_OPEN_SH_MEM_FUNC, osCloseHandle, osCreateSharedMemory, osGetLastError, PVOID, shared memory objects, SYSNAME, system objects management |