DosAllocSharedMem allocates a shared memory object within the virtual-address space.
Allocating a shared memory object causes the creation of an object that describes a region of memory that can be shared. The virtual-address space in the calling process is allocated and mapped to the shared memory object.
The virtual-address space for a shared memory object is reserved at the same location in the virtual address space of every process. This allows any process to gain access to the shared object at the same virtual address where it was originally allocated.
When the shared memory object is given a name, the shared memory object can be shared by other processes that gain access through the shared memory name (see DosGetNamedSharedMem).
To specify the name for the shared memory object, the name string provided must include the prefix "\SHAREMEM\".
It is an error to request giveable or gettable named shared memory.
To allocate unnamed shared memory, set the pszName parameter to NULL.
If the shared memory object is unnamed, it may be specified as giveable (OBJ_GIVEABLE) or gettable (OBJ_GETTABLE). Unnamed shared memory may be shared by all processes that get access to the shared memory object (see DosGetSharedMem), or are given access to the shared memory object (see DosGiveSharedMem).
It is an error to request non-giveable or non-gettable unnamed shared memory.
The allocated memory object is rounded up to a multiple of 4KB in size.
The committed memory allocated by DosAllocSharedMem is movable and can be swapped.
With the Intel 80386 processor, execute and read access are equivalent. Also, write access implies both read and execute access.
The tiled allocation attribute is provided for compatibility with the existing 16-bit implementation of the operating system. If the shared memory object is tiled, the virtual address for the shared memory object will be within the first 512MB of the virtual address space, with 16-bit selectors mapping the memory object.
Note: DosAllocMem and DosAllocSharedMem both allocate a block of memory of the size requested rounded up to the nearest page. On OS/2 Warp, the system allocates a 64K object without attributes on every allocation.
For example, for a DosAllocSharedMem call with a size of 1, the system allocates a 4096-byte block of committed memory plus 61440 bytes without attributes.
Note:
When you allocate a memory object with the PAG_EXECUTE attribute, it is implied that this memory object also has the PAG_READ attribute. However, when querying the attributes of a memory object, you will get the following results: