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 revision
Previous revision
en:docs:fapi:dosallochuge [2021/09/15 13:29] prokusheven:docs:fapi:dosallochuge [2021/10/16 14:05] (current) prokushev
Line 1: Line 1:
-{{logos:os2.gif?35x35}} {{logos:dos.gif?35x35}}+{{page>en:templates:fapiint}} 
  
 ====== DosAllocHuge ====== ====== DosAllocHuge ======
Line 13: Line 14:
 ===== 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. |
 | 3  | If segment is shared, it can be decreased in size by [[DosReallocHuge]]. | | 3  | If segment is shared, it can be decreased in size by [[DosReallocHuge]]. |
Line 35: Line 36:
 ===== Return Code ===== ===== Return Code =====
  
-  rc (USHORT) - return+rc ([[USHORT]]) - return
  
 Return code descriptions are: Return code descriptions are:
Line 51: Line 52:
  
   * 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.
  
 Applications should be discretionary in claiming large memory when doing so can impair system performance. To test system memory availability, issue [[DosMemAvail]]. This call returns the size of the largest block of unallocated memory. Although this value can change at any time because of system activity, it can provide a good indication of the system memory state. Applications should be discretionary in claiming large memory when doing so can impair system performance. To test system memory availability, issue [[DosMemAvail]]. This call returns the size of the largest block of unallocated memory. Although this value can change at any time because of system activity, it can provide a good indication of the system memory state.
  
-Memory allocated by DosAllocHuge is freed by DosFreeSeg. One call to DosFreeSeg, passing the selector returned from a DosAllocHuge, frees all of the memory allocated.+Memory allocated by DosAllocHuge is freed by [[DosFreeSeg]]. One call to [[DosFreeSeg]], passing the selector returned from a DosAllocHuge, frees all of the memory allocated.
  
 **Note:** This request may be issued from privilege level 2. However, the segment is allocated as a privilege level 3 segment. **Note:** This request may be issued from privilege level 2. However, the segment is allocated as a privilege level 3 segment.
  
-===Family API Considerations===+==== Family API Considerations ===
  
 Some options operate differently in the DOS mode than in the OS/2 mode. Therefore, the following considerations apply to DosAllocHuge when coding for the DOS mode: Some options operate differently in the DOS mode than in the OS/2 mode. Therefore, the following considerations apply to DosAllocHuge when coding for the DOS mode:
Line 69: Line 71:
   * Selector is the actual segment address allocated.    * Selector is the actual segment address allocated. 
  
-==Example Code== +===== Example Code ===== 
-=== C Binding===+ 
 +==== C Binding ====
  
 <code c> <code c>
Line 87: Line 90:
 </code> </code>
  
-=== Example ===+==== Example ====
  
 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. 
Line 109: Line 112:
 </code> </code>
  
-=== ASM Binding ===+==== MASM Binding ===
 <code asm> <code asm>
   EXTRN  DosAllocHuge:FAR   EXTRN  DosAllocHuge:FAR
Line 123: Line 127:
   Returns WORD   Returns WORD
 </code> </code>
-====== Note ======+===== Note =====
  
 Text based on [[http://www.edm2.com/index.php/DosAllocHuge]] Text based on [[http://www.edm2.com/index.php/DosAllocHuge]]