Difference between revisions of "DosGiveSeg"

From EDM2
Jump to: navigation, search
m
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
+
This call allows another process to access shared memory allocated by a [[DosAllocSeg]] or [[DosAllocHuge]] call.
This call allows another process to access shared memory allocated by a DosAllocSeg or DosAllocHuge call.
+
  
 
==Syntax==
 
==Syntax==
<PRE>
+
  DosGiveSeg (CallerSegSelector, ProcessID, RecipientSegSelector)
  DosGiveSeg
+
  
    (CallerSegSelector, ProcessID, RecipientSegSelector)
 
</PRE>
 
 
==Parameters==
 
==Parameters==
; CallerSegSelector (SEL) - input : Segment selector of the shared memory segment.  
+
;CallerSegSelector (SEL) - input : Segment selector of the shared memory segment.
 
+
;ProcessID (PID) - input : Process ID of the process to receive access to the shared memory segment.
; ProcessID (PID) - input : Process ID of the process to receive access to the shared memory segment.  
+
;RecipientSegSelector (PSEL) - output : Address of the recipient's segment selector.
 
+
; RecipientSegSelector (PSEL) - output : Address of the recipient's segment selector.
+
  
 
==Return Code==
 
==Return Code==
rc (USHORT) - return
+
;rc (USHORT) - return:Return code descriptions are:
 
+
*0 NO_ERROR
Return code descriptions are:
+
*5 ERROR_ACCESS_DENIED
 
+
*8 ERROR_NOT_ENOUGH_MEMORY
* 0       NO_ERROR  
+
* 5       ERROR_ACCESS_DENIED  
+
* 8       ERROR_NOT_ENOUGH_MEMORY
+
  
 
==Remarks==
 
==Remarks==
Line 29: Line 20:
 
If the memory being given was allocated by a DosAllocHuge request, the CallerSegSelector must be the base selector returned by DosAllocHuge. When the caller passes the selector returned in RecipientSegSelector to the intended sharer, this selector has addressability only to the first segment in the sharer's address space of the huge allocation. However, the recipient can call DosGetHugeShift and use the shift count returned to calculate the selectors for the remaining segments.  
 
If the memory being given was allocated by a DosAllocHuge request, the CallerSegSelector must be the base selector returned by DosAllocHuge. When the caller passes the selector returned in RecipientSegSelector to the intended sharer, this selector has addressability only to the first segment in the sharer's address space of the huge allocation. However, the recipient can call DosGetHugeShift and use the shift count returned to calculate the selectors for the remaining segments.  
  
==Example Code==
+
==Bindings==
===C Binding===
+
===C===
 
<PRE>
 
<PRE>
 
#define INCL_DOSMEMMGR
 
#define INCL_DOSMEMMGR
Line 36: Line 27:
 
USHORT  rc = DosGiveSeg(CallerSegSelector, ProcessID, RecipientSegSelector);
 
USHORT  rc = DosGiveSeg(CallerSegSelector, ProcessID, RecipientSegSelector);
  
SEL           CallerSegSelector;    /* Caller's segment selector */
+
SEL     CallerSegSelector;    /* Caller's segment selector */
PID           ProcessID;            /* Process ID of recipient */
+
PID     ProcessID;            /* Process ID of recipient */
PSEL         RecipientSegSelector; /* Recipient's segment selector
+
PSEL   RecipientSegSelector; /* Recipient's segment selector (returned) */
                                        (returned) */
+
  
USHORT       rc;                  /* return code */
+
USHORT rc;                  /* return code */
 
</PRE>
 
</PRE>
  
===MASM Binding===
+
===MASM===
 
<PRE>
 
<PRE>
 
EXTRN  DosGiveSeg:FAR
 
EXTRN  DosGiveSeg:FAR
Line 56: Line 46:
 
Returns WORD
 
Returns WORD
 
</PRE>
 
</PRE>
==Related Functions==
 
*
 
 
  
[[Category:Dos]]
+
[[Category:Dos16]]

Latest revision as of 02:37, 26 January 2020

This call allows another process to access shared memory allocated by a DosAllocSeg or DosAllocHuge call.

Syntax

DosGiveSeg (CallerSegSelector, ProcessID, RecipientSegSelector)

Parameters

CallerSegSelector (SEL) - input 
Segment selector of the shared memory segment.
ProcessID (PID) - input 
Process ID of the process to receive access to the shared memory segment.
RecipientSegSelector (PSEL) - output 
Address of the recipient's segment selector.

Return Code

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

Remarks

DosGiveSeg returns a selector that can be given to another process to access shared memory the giver has allocated by a DosAllocSeg or DosAllocHuge call. The giving process passes the recipient's selector to the intended sharer by some means of interprocess communication. If the recipient has created a queue with DosCreateQueue, the giver can issue DosWriteQueue, specifying the queue name, and pass the selector in this manner.

If the memory being given was allocated by a DosAllocHuge request, the CallerSegSelector must be the base selector returned by DosAllocHuge. When the caller passes the selector returned in RecipientSegSelector to the intended sharer, this selector has addressability only to the first segment in the sharer's address space of the huge allocation. However, the recipient can call DosGetHugeShift and use the shift count returned to calculate the selectors for the remaining segments.

Bindings

C

#define INCL_DOSMEMMGR

USHORT  rc = DosGiveSeg(CallerSegSelector, ProcessID, RecipientSegSelector);

SEL     CallerSegSelector;    /* Caller's segment selector */
PID     ProcessID;            /* Process ID of recipient */
PSEL    RecipientSegSelector; /* Recipient's segment selector (returned) */

USHORT  rc;                   /* return code */

MASM

EXTRN  DosGiveSeg:FAR
INCL_DOSMEMMGR      EQU 1

PUSH   WORD    CallerSegSelector    ;Caller's segment selector
PUSH   WORD    ProcessID            ;Process ID of recipient
PUSH@  WORD    RecipientSegSelector ;Recipient's segment selector (returned)
CALL   DosGiveSeg

Returns WORD