Jump to content

DosUnlockSeg: Difference between revisions

From EDM2
Created page with "==Description== This call unlocks a discardable segment. ==Syntax== <PRE> DosUnlockSeg (Selector) </PRE> ==Parameters== ; Selector (SEL) - input : Segment selector to ..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
This call unlocks a discardable segment.
This call unlocks a discardable segment.


==Syntax==
==Syntax==
<PRE>
  DosUnlockSeg (Selector)
  DosUnlockSeg


    (Selector)
</PRE>
==Parameters==
==Parameters==
; Selector (SEL) - input : Segment selector to be unlocked.
;Selector (SEL) - input : Segment selector to be unlocked.


==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
 
*158 ERROR_NOT_LOCKED
* 0         NO_ERROR
* 5         ERROR_ACCESS_DENIED
* 158       ERROR_NOT_LOCKED


==Remarks==
==Remarks==
DosUnlockSeg is called to free memory for possible discard by the system in a low memory situation. The memory being freed is originally allocated by a call to DosAllocSeg or DosAllocHuge with AllocFlags bit 2 set. This memory may have been reallocated by a call to DosReallocSeg or DosReallocHuge after discard by the system.
DosUnlockSeg is called to free memory for possible discard by the system in a low memory situation. The memory being freed is originally allocated by a call to [[DosAllocSeg]] or [[DosAllocHuge]] with AllocFlags bit 2 set. This memory may have been reallocated by a call to [[DosReallocSeg]] or [[DosReallocHuge]] after discard by the system.


Allocation and reallocation calls for discardable memory automatically lock the memory for access by the calling process. Thus, to access the segment, the caller does not have to lock the segment with DosLockSeg. Once a discardable segment is unlocked by a DosUnlockSeg request, access to the segment is gained by a successful DosLockSeg request.
Allocation and reallocation calls for discardable memory automatically lock the memory for access by the calling process. Thus, to access the segment, the caller does not have to lock the segment with [[DosLockSeg]]. Once a discardable segment is unlocked by a DosUnlockSeg request, access to the segment is gained by a successful DosLockSeg request.


DosUnlockSeg may also be used on segments that are non-discardable, in which case it has no effect.  
DosUnlockSeg may also be used on segments that are non-discardable, in which case it has no effect.


==Example Code==
==Bindings==
=== C Binding===
===C===
<PRE>
<PRE>
#define INCL_DOSMEMMGR
#define INCL_DOSMEMMGR
Line 34: Line 27:
USHORT  rc = DosUnlockSeg(Selector);
USHORT  rc = DosUnlockSeg(Selector);


SEL             Selector;      /* Selector to unlock */
SEL     Selector;      /* Selector to unlock */


USHORT           rc;            /* return code */
USHORT rc;            /* return code */
</PRE>
</PRE>
===MASM Binding===
===MASM===
<PRE>
<PRE>
EXTRN  DosUnlockSeg:FAR
EXTRN  DosUnlockSeg:FAR
Line 48: Line 41:
Returns WORD
Returns WORD
</PRE>
</PRE>
==Related Functions==
*


[[Category:The OS/2 API Project]]
[[Category:Dos16]]

Latest revision as of 02:36, 26 January 2020

This call unlocks a discardable segment.

Syntax

DosUnlockSeg (Selector)

Parameters

Selector (SEL) - input
Segment selector to be unlocked.

Return Code

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

Remarks

DosUnlockSeg is called to free memory for possible discard by the system in a low memory situation. The memory being freed is originally allocated by a call to DosAllocSeg or DosAllocHuge with AllocFlags bit 2 set. This memory may have been reallocated by a call to DosReallocSeg or DosReallocHuge after discard by the system.

Allocation and reallocation calls for discardable memory automatically lock the memory for access by the calling process. Thus, to access the segment, the caller does not have to lock the segment with DosLockSeg. Once a discardable segment is unlocked by a DosUnlockSeg request, access to the segment is gained by a successful DosLockSeg request.

DosUnlockSeg may also be used on segments that are non-discardable, in which case it has no effect.

Bindings

C

#define INCL_DOSMEMMGR

USHORT  rc = DosUnlockSeg(Selector);

SEL     Selector;      /* Selector to unlock */

USHORT  rc;            /* return code */

MASM

EXTRN  DosUnlockSeg:FAR
INCL_DOSMEMMGR      EQU 1

PUSH   WORD Selector         ;Selector to unlock
CALL   DosUnlockSeg

Returns WORD