en:docs:fapi:dosallochuge

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
en:docs:fapi:dosallochuge [2021/08/14 10:00] prokusheven:docs:fapi:dosallochuge [2021/09/14 14:17] prokushev
Line 7: Line 7:
 ===== Syntax ===== ===== Syntax =====
  
-  DosAllocHuge (NumSeg, Size, Selector, MaxNumSeg, AllocFlags)+<code c> 
 +DosAllocHuge (NumSeg, Size, Selector, MaxNumSeg, AllocFlags) 
 +</code>
  
 ===== Parameters ===== ===== Parameters =====
  
-  NumSeg (USHORT) - input : Number of 65536-byte segments to be allocated. +  NumSeg (USHORT) - input : Number of 65536-byte segments to be allocated. 
-  Size (USHORT) - input : Number of bytes to be allocated in the last (non-65536-byte) segment. A value of zero indicates none. +  Size (USHORT) - input : Number of bytes to be allocated in the last (non-65536-byte) segment. A value of zero indicates none. 
-  Selector (PSEL) - output : Address where the selector of the first segment allocated is returned. +  Selector (PSEL) - output : Address where the selector of the first segment allocated is returned. 
-  MaxNumSeg (USHORT) - input : Maximum number of 65536-byte segments this object occupies as a result of any subsequent [[DosReallocHuge]]. If MaxNumSeg is 0, OS/2 assumes this segment will never be increased by DosReallocHuge beyond its original size, though it may be decreased. This value is ignored in the DOS mode. +  MaxNumSeg (USHORT) - input : Maximum number of 65536-byte segments this object occupies as a result of any subsequent [[DosReallocHuge]]. If MaxNumSeg is 0, OS/2 assumes this segment will never be increased by DosReallocHuge beyond its original size, though it may be decreased. This value is ignored in the DOS mode. 
-  AllocFlags (USHORT) - input : Bit indicators describing the characteristics of the segment allocated. The bits that can be set and their meanings are:+  AllocFlags (USHORT) - input : Bit indicators describing the characteristics of the segment allocated. The bits that can be set and their meanings are: 
 ^ Bit ^        Description ^ ^ Bit ^        Description ^
 | 15-4 |       Reserved and must be set to zero. | | 15-4 |       Reserved and must be set to zero. |
Line 40: Line 43:
 Each segment of a huge memory allocation has a unique selector. To determine the remaining selectors of a huge memory allocation, issue [[DosGetHugeShift]], which returns a shift count. To compute the next sequential selector, take the value 1 and shift it left by the number of bits specified in shift count. Use the resulting value as an increment to add to the previous selector, using the selector returned by DosAllocHuge as the first selector. For example: Each segment of a huge memory allocation has a unique selector. To determine the remaining selectors of a huge memory allocation, issue [[DosGetHugeShift]], which returns a shift count. To compute the next sequential selector, take the value 1 and shift it left by the number of bits specified in shift count. Use the resulting value as an increment to add to the previous selector, using the selector returned by DosAllocHuge as the first selector. For example:
  
-* Assume DosAllocHuge is issued with NumSeg equal to 3, and that the number 63 is returned for the selector of the first segment.  +  * Assume DosAllocHuge is issued with NumSeg equal to 3, and that the number 63 is returned for the selector of the first segment.  
-* If DosGetHugeShift returns a shift count of 4, shifting the value "1" by this amount results in an increment of 16. +  * If DosGetHugeShift returns a shift count of 4, shifting the value "1" by this amount results in an increment of 16. 
-* Adding this increment to selector number 63 produces 79 for the second selector. Adding the same increment to selector number 79 yields 95 for the third selector.+  * Adding this increment to selector number 63 produces 79 for the second selector. Adding the same increment to selector number 79 yields 95 for the third selector.
  
 Like single segment memory allocated with DosAllocSeg, huge memory can be designated as shareable by other processes and discardable by the system when no longer needed. Allocating a huge block of memory as discardable automatically locks the memory for use by the caller. When one segment of a huge allocation is discarded by the system, this forces the discard of all the other segments. See DosAllocSeg for more information relating to discardable and shared segments. Like single segment memory allocated with DosAllocSeg, huge memory can be designated as shareable by other processes and discardable by the system when no longer needed. Allocating a huge block of memory as discardable automatically locks the memory for use by the caller. When one segment of a huge allocation is discarded by the system, this forces the discard of all the other segments. See DosAllocSeg for more information relating to discardable and shared segments.
Line 62: Line 65:
 === C Binding=== === C Binding===
  
 +<code c>
   #define INCL_DOSMEMMGR   #define INCL_DOSMEMMGR
      
Line 74: Line 78:
      
   USHORT           rc;            /* return code */   USHORT           rc;            /* return code */
 +</code>
  
 === Example === === Example ===
Line 80: Line 84:
 This example requests a block of memory with 4 segments, the last segment having 1,040 bytes. The block of memory will never be larger than 8 segments. The memory can be shared with DosGiveSeg API calls. The system can discard the memory if it needs too.  This example requests a block of memory with 4 segments, the last segment having 1,040 bytes. The block of memory will never be larger than 8 segments. The memory can be shared with DosGiveSeg API calls. The system can discard the memory if it needs too. 
  
 +<code c>
   #define INCL_DOSMEMMGR   #define INCL_DOSMEMMGR
      
Line 95: Line 100:
                     MAXIMUM_SEG_SIZE,       /* Max number of segments */                     MAXIMUM_SEG_SIZE,       /* Max number of segments */
                     ALLOC_FLAG);            /* Allocation flags */                     ALLOC_FLAG);            /* Allocation flags */
 +</code>
  
 === ASM Binding === === ASM Binding ===
 +<code asm>
   EXTRN  DosAllocHuge:FAR   EXTRN  DosAllocHuge:FAR
   INCL_DOSMEMMGR      EQU 1   INCL_DOSMEMMGR      EQU 1
Line 109: Line 115:
      
   Returns WORD   Returns WORD
 +</code>
 ====== Note ====== ====== Note ======