dos12.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DosUnlockSeg (1.2)
Function Group  Overview                          Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_DOSMEMMGR
 
USHORT DosUnlockSeg(sel)
SEL sel;    /* selector of segment to unlock */
 
The DosUnlockSeg function unlocks a discardable segment. Once a segment is
unlocked, the system may discard it to make space available for other
segments.
 
Parameter  Description
────────────────────────────────────────────────────────────────────────────
 
sel        Specifies the selector of the segment to unlock.
 
Return Value
 
The return value is zero if the function is successful. Otherwise, it is an
error value.
 
Comments
 
DosUnlockSeg applies only to segments that are allocated by using the
DosAllocSeg function with the fsAlloc parameter set to SEG_DISCARDABLE.
 
The DosLockSeg and DosUnlockSeg functions can be nested. If DosLockSeg is
called 5 times to lock a segment, DosUnlockSeg must be called 5 times to
unlock the segment. A segment becomes permanently locked if it is locked 255
times without being unlocked. Note that locks are an attribute of the
segment, not of a process. If one process unlocks a shared segment in use by
a second, and the second process has not called DosLockSeg, the segment is
marked as discardable. If it is discarded, the first process will be
terminated. To prevent this, all processes accessing shared memory should
use DosLockSeg or DosReallocSeg to ensure that the segment being accessed is
valid.
 
See Also
 
DosAllocSeg, DosLockSeg, DosReallocSeg