Jump to content

DosGetSeg: Difference between revisions

From EDM2
No edit summary
Ak120 (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Legacy
|RepFunc=
|Remarks=This page list the older version of the function for reference.
}}
This call accesses shared memory allocated by a DosAllocSeg or DosAllocHuge call.
This call accesses shared memory allocated by a DosAllocSeg or DosAllocHuge call.


Line 12: Line 8:


==Return Code==
==Return Code==
rc (USHORT) - return
;rc (USHORT) - return: Return code descriptions are:
Return code descriptions are:
* 0 NO_ERROR
* 0 NO_ERROR
* 5 ERROR_ACCESS_DENIED  
* 5 ERROR_ACCESS_DENIED  


==Remarks==
==Remarks==
A process may issue DosAllocSeg or DosAllocHuge to allocate shareable segments of memory. The segment may be shareable through DosGiveSeg or DosGetSeg. If the segment is shareable through DosGetSeg, then the process that allocated the memory must pass the selector of the segment to the recipient process using some means of interprocess communication.
A process may issue [[DosAllocSeg]] or [[DosAllocHuge]] to allocate shareable segments of memory. The segment may be shareable through [[DosGiveSeg]] or DosGetSeg. If the segment is shareable through DosGetSeg, then the process that allocated the memory must pass the selector of the segment to the recipient process using some means of interprocess communication.


If at the time the shared segment is allocated, it is also specified as discardable, it is automatically locked for access by the caller. The caller may free the segment for discard by a DosUnlockSeg call. A process that gains access to the discardable shared segment by calling DosGetSeg has to lock the segment with a DosLockSeg request. However, DosLockSeg may return an error, indicating the segment is already locked. In this case, the process calls DosUnlockSeg repetitively, until the segment is fully unlocked. The process then locks the segment for its own use. Locking is an attribute of the segment, not the processes using the segment.
If at the time the shared segment is allocated, it is also specified as discardable, it is automatically locked for access by the caller. The caller may free the segment for discard by a [[DosUnlockSeg]] call. A process that gains access to the discardable shared segment by calling DosGetSeg has to lock the segment with a [[DosLockSeg]] request. However, DosLockSeg may return an error, indicating the segment is already locked. In this case, the process calls DosUnlockSeg repetitively, until the segment is fully unlocked. The process then locks the segment for its own use. Locking is an attribute of the segment, not the processes using the segment.


To access named shared memory allocated with a DosAllocShrSeg request, a process issues DosGetShrSeg.  
To access named shared memory allocated with a [[DosAllocShrSeg]] request, a process issues [[DosGetShrSeg]].


==Example Code==
==Bindings==
=== C Binding===
=== C ===
<PRE>
<PRE>
#define INCL_DOSMEMMGR
#define INCL_DOSMEMMGR


USHORT  rc = DosGetSeg(Selector);
USHORT  rc = DosGetSeg(Selector);
 
SEL     Selector;      /* Selector to access */
SEL             Selector;      /*Selector to access */
USHORT rc;            /* return code */
 
USHORT           rc;            /* return code */
</PRE>
</PRE>


===MASM Binding===
===MASM ===
<PRE>
<PRE>
EXTRN  DosGetSeg:FAR
EXTRN  DosGetSeg:FAR
Line 47: Line 40:
</PRE>
</PRE>


==Related Functions==
[[Category:Dos16]]
*
 
[[Category:Dos]]

Latest revision as of 04:31, 26 January 2020

This call accesses shared memory allocated by a DosAllocSeg or DosAllocHuge call.

Syntax

DosGetSeg (Selector)

Parameters

Selector (SEL) - input
Parameter used to get access to a segment.

Return Code

rc (USHORT) - return
Return code descriptions are:
  • 0 NO_ERROR
  • 5 ERROR_ACCESS_DENIED

Remarks

A process may issue DosAllocSeg or DosAllocHuge to allocate shareable segments of memory. The segment may be shareable through DosGiveSeg or DosGetSeg. If the segment is shareable through DosGetSeg, then the process that allocated the memory must pass the selector of the segment to the recipient process using some means of interprocess communication.

If at the time the shared segment is allocated, it is also specified as discardable, it is automatically locked for access by the caller. The caller may free the segment for discard by a DosUnlockSeg call. A process that gains access to the discardable shared segment by calling DosGetSeg has to lock the segment with a DosLockSeg request. However, DosLockSeg may return an error, indicating the segment is already locked. In this case, the process calls DosUnlockSeg repetitively, until the segment is fully unlocked. The process then locks the segment for its own use. Locking is an attribute of the segment, not the processes using the segment.

To access named shared memory allocated with a DosAllocShrSeg request, a process issues DosGetShrSeg.

Bindings

C

#define INCL_DOSMEMMGR

USHORT  rc = DosGetSeg(Selector);
SEL     Selector;      /* Selector to access */
USHORT  rc;            /* return code */

MASM

EXTRN  DosGetSeg:FAR
INCL_DOSMEMMGR      EQU 1

PUSH   WORD    Selector      ;Selector to access
CALL   DosGetSeg

Returns WORD