DosLockSeg: Difference between revisions
mNo edit summary |
mNo edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This call locks a discardable segment in memory. | This call locks a discardable segment in memory. | ||
==Syntax== | ==Syntax== | ||
Line 10: | Line 8: | ||
==Return Code== | ==Return Code== | ||
;rc (USHORT) - return:Return code descriptions are: | |||
Return code descriptions are: | * 0 NO_ERROR | ||
* 0 | * 5 ERROR_ACCESS_DENIED | ||
* 5 | *157 ERROR_DISCARDED | ||
* 157 | |||
==Remarks== | ==Remarks== | ||
Discardable segments are useful for holding objects that are accessed for short periods of time and that can be regenerated quickly if discarded. Examples are cache buffers for a data base package, saved bitmap images for obscured windows or precomputed display images for a word processing application. | Discardable segments are useful for holding objects that are accessed for short periods of time and that can be regenerated quickly if discarded. Examples are cache buffers for a data base package, saved bitmap images for obscured windows or precomputed display images for a word processing application. | ||
Discardable memory is allocated by a call to DosAllocSeg or DosAllocHuge with AllocFlags bit 2 set. Upon allocation, the memory is automatically locked for access by the allocating process and cannot be discarded. After the segment is unlocked by a DosUnlockSeg request, the memory can be discarded by the memory manager to remedy a low memory situation. Once memory is discarded, a DosLockSeg call returns ERROR_DISCARDED. The memory is reallocated by a call to DosReallocSeg or DosReallocHuge. The reallocation request automatically locks the memory. | Discardable memory is allocated by a call to [[DosAllocSeg]] or [[DosAllocHuge]] with AllocFlags bit 2 set. Upon allocation, the memory is automatically locked for access by the allocating process and cannot be discarded. After the segment is unlocked by a [[DosUnlockSeg]] request, the memory can be discarded by the memory manager to remedy a low memory situation. Once memory is discarded, a DosLockSeg call returns ERROR_DISCARDED. The memory is reallocated by a call to [[DosReallocSeg]] or [[DosReallocHuge]]. The reallocation request automatically locks the memory. | ||
Memory allocated as discardable by a DosAllocSeg or DosAllocHuge request may also have been designated as shareable. Sharing processes that access the discardable shared memory with DosGetSeg have to lock the memory by calling DosLockSeg. See DosGetSeg for more information. | Memory allocated as discardable by a DosAllocSeg or DosAllocHuge request may also have been designated as shareable. Sharing processes that access the discardable shared memory with [[DosGetSeg]] have to lock the memory by calling DosLockSeg. See DosGetSeg for more information. | ||
DosLockSeg and DosUnlockSeg calls may be nested. If DosLockSeg is called multiple times to lock a segment, the same number of calls must be made to DosUnlockSeg before the segment is unlocked. However, if a segment is locked 255 times, it becomes permanently locked. Additional calls to DosLockSeg and DosUnlockSeg have no effect on the segment's locked state. | DosLockSeg and DosUnlockSeg calls may be nested. If DosLockSeg is called multiple times to lock a segment, the same number of calls must be made to DosUnlockSeg before the segment is unlocked. However, if a segment is locked 255 times, it becomes permanently locked. Additional calls to DosLockSeg and DosUnlockSeg have no effect on the segment's locked state. | ||
This function is used on segments that have been allocated through DosAllocSeg with AllocFlags bit 2 (0100B) set. It may be also used on segments that are non-discardable, in which case it has no effect. | This function is used on segments that have been allocated through DosAllocSeg with AllocFlags bit 2 (0100B) set. It may be also used on segments that are non-discardable, in which case it has no effect. | ||
== | ==Bindings== | ||
=== C | === C === | ||
<PRE> | <PRE> | ||
#define INCL_DOSMEMMGR | #define INCL_DOSMEMMGR | ||
Line 34: | Line 31: | ||
USHORT rc = DosLockSeg(Selector); | USHORT rc = DosLockSeg(Selector); | ||
SEL | SEL Selector; /* Selector to lock */ | ||
USHORT rc; /* return code */ | |||
USHORT | |||
</PRE> | </PRE> | ||
===MASM | ===MASM=== | ||
<PRE> | <PRE> | ||
EXTRN DosLockSeg:FAR | EXTRN DosLockSeg:FAR | ||
Line 50: | Line 46: | ||
</PRE> | </PRE> | ||
[[Category:Dos16]] | |||
[[Category: |
Latest revision as of 02:35, 26 January 2020
This call locks a discardable segment in memory.
Syntax
DosLockSeg (Selector)
Parameters
- Selector (SEL) - input
- Selector of the segment to be locked.
Return Code
- rc (USHORT) - return
- Return code descriptions are:
- 0 NO_ERROR
- 5 ERROR_ACCESS_DENIED
- 157 ERROR_DISCARDED
Remarks
Discardable segments are useful for holding objects that are accessed for short periods of time and that can be regenerated quickly if discarded. Examples are cache buffers for a data base package, saved bitmap images for obscured windows or precomputed display images for a word processing application.
Discardable memory is allocated by a call to DosAllocSeg or DosAllocHuge with AllocFlags bit 2 set. Upon allocation, the memory is automatically locked for access by the allocating process and cannot be discarded. After the segment is unlocked by a DosUnlockSeg request, the memory can be discarded by the memory manager to remedy a low memory situation. Once memory is discarded, a DosLockSeg call returns ERROR_DISCARDED. The memory is reallocated by a call to DosReallocSeg or DosReallocHuge. The reallocation request automatically locks the memory.
Memory allocated as discardable by a DosAllocSeg or DosAllocHuge request may also have been designated as shareable. Sharing processes that access the discardable shared memory with DosGetSeg have to lock the memory by calling DosLockSeg. See DosGetSeg for more information.
DosLockSeg and DosUnlockSeg calls may be nested. If DosLockSeg is called multiple times to lock a segment, the same number of calls must be made to DosUnlockSeg before the segment is unlocked. However, if a segment is locked 255 times, it becomes permanently locked. Additional calls to DosLockSeg and DosUnlockSeg have no effect on the segment's locked state.
This function is used on segments that have been allocated through DosAllocSeg with AllocFlags bit 2 (0100B) set. It may be also used on segments that are non-discardable, in which case it has no effect.
Bindings
C
#define INCL_DOSMEMMGR USHORT rc = DosLockSeg(Selector); SEL Selector; /* Selector to lock */ USHORT rc; /* return code */
MASM
EXTRN DosLockSeg:FAR INCL_DOSMEMMGR EQU 1 PUSH WORD Selector ;Selector to lock CALL DosLockSeg Returns WORD