DosGetShrSeg: Difference between revisions
Appearance
m Ak120 moved page OS2 API:CPI:LEGACY:DosGetShrSeg to DosGetShrSeg |
mNo edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This call accesses a shared memory segment previously allocated by another process. | This call accesses a shared memory segment previously allocated by another process. | ||
==Syntax== | ==Syntax== | ||
DosGetShrSeg (Name, Selector) | |||
DosGetShrSeg | |||
==Parameters== | ==Parameters== | ||
; | ;Name (PSZ) - input : Address of the name string associated with the shared memory segment to be accessed. The name is an ASCIIZ string in the format of an OS/2 filename in a subdirectory called \SHAREMEM\, for example, \SHAREMEM\PUBLIC.DAT. | ||
;Selector (PSEL) - output : Address of the selector for the shared memory segment. | |||
; Selector (PSEL) - output : Address of the selector for the shared memory segment. | |||
==Return Code== | ==Return Code== | ||
;rc (USHORT) - return:Return code descriptions are: | |||
*0 NO_ERROR | |||
Return code descriptions are: | *2 ERROR_FILE_NOT_FOUND | ||
*4 ERROR_TOO_MANY_OPEN_FILES | |||
* 0 | *123 ERROR_INVALID_NAME | ||
* 2 | |||
* 4 | |||
* 123 | |||
==Remarks== | ==Remarks== | ||
DosGetShrSeg provides access to a named shared segment allocated by another process with DosAllocShrSeg. The selector returned by DosGetShrSeg is the same as the one returned by the DosAllocShrSeg call. | DosGetShrSeg provides access to a named shared segment allocated by another process with [[DosAllocShrSeg]]. The selector returned by DosGetShrSeg is the same as the one returned by the DosAllocShrSeg call. | ||
A usage count is maintained for a named shared segment. Issuing DosGetShrSeg increments the count, and issuing DosFreeSeg decrements the count. When the usage count equals zero, the named shared segment is deallocated. Once the segment has been deallocated, it must be reinitialized by a call to DosAllocShrSeg. | A usage count is maintained for a named shared segment. Issuing DosGetShrSeg increments the count, and issuing [[DosFreeSeg]] decrements the count. When the usage count equals zero, the named shared segment is deallocated. Once the segment has been deallocated, it must be reinitialized by a call to DosAllocShrSeg. | ||
To access shared memory that is allocated by another process with DosAllocSeg and DosAllocHuge requests, a process issues DosGetSeg. | To access shared memory that is allocated by another process with [[DosAllocSeg]] and [[DosAllocHuge]] requests, a process issues [[DosGetSeg]]. | ||
==Bindings== | |||
== | ===C=== | ||
===C | |||
<PRE> | <PRE> | ||
#define INCL_DOSMEMMGR | #define INCL_DOSMEMMGR | ||
Line 38: | Line 29: | ||
USHORT rc = DosGetShrSeg(Name, Selector); | USHORT rc = DosGetShrSeg(Name, Selector); | ||
PSZ | PSZ Name; /* Name string */ | ||
PSEL | PSEL Selector; /* Selector of shared segment */ | ||
USHORT | USHORT rc; /* return code /* | ||
</PRE> | </PRE> | ||
===MASM | ===MASM=== | ||
<PRE> | <PRE> | ||
EXTRN DosGetShrSeg:FAR | EXTRN DosGetShrSeg:FAR | ||
Line 55: | Line 46: | ||
Returns WORD | Returns WORD | ||
</PRE> | </PRE> | ||
[[Category: | [[Category:Dos16]] |
Latest revision as of 04:32, 26 January 2020
This call accesses a shared memory segment previously allocated by another process.
Syntax
DosGetShrSeg (Name, Selector)
Parameters
- Name (PSZ) - input
- Address of the name string associated with the shared memory segment to be accessed. The name is an ASCIIZ string in the format of an OS/2 filename in a subdirectory called \SHAREMEM\, for example, \SHAREMEM\PUBLIC.DAT.
- Selector (PSEL) - output
- Address of the selector for the shared memory segment.
Return Code
- rc (USHORT) - return
- Return code descriptions are:
- 0 NO_ERROR
- 2 ERROR_FILE_NOT_FOUND
- 4 ERROR_TOO_MANY_OPEN_FILES
- 123 ERROR_INVALID_NAME
Remarks
DosGetShrSeg provides access to a named shared segment allocated by another process with DosAllocShrSeg. The selector returned by DosGetShrSeg is the same as the one returned by the DosAllocShrSeg call.
A usage count is maintained for a named shared segment. Issuing DosGetShrSeg increments the count, and issuing DosFreeSeg decrements the count. When the usage count equals zero, the named shared segment is deallocated. Once the segment has been deallocated, it must be reinitialized by a call to DosAllocShrSeg.
To access shared memory that is allocated by another process with DosAllocSeg and DosAllocHuge requests, a process issues DosGetSeg.
Bindings
C
#define INCL_DOSMEMMGR USHORT rc = DosGetShrSeg(Name, Selector); PSZ Name; /* Name string */ PSEL Selector; /* Selector of shared segment */ USHORT rc; /* return code /*
MASM
EXTRN DosGetShrSeg:FAR INCL_DOSMEMMGR EQU 1 PUSH@ ASCIIZ Name ;Name string PUSH@ WORD Selector ;Selector of shared segment (returned) CALL DosGetShrSeg Returns WORD