www.beck-ipc.com

@CHIP-RTOS C Library - BIOS API


BIOS_Set_Memory_Gap

Set the memory gap used between the loaded DOS programs.

int BIOS_Set_Memory_Gap ( unsigned int paragraphs );

Parameters

paragraphs

Size of memory gap in 16 byte (SC1x) or 256 byte (SC2x/SC1x3) paragraphs:   range [0 .. 2048]

Return Value

0:  Successful
-1:  Failure, invalid value in paragraphs

Comments

This function sets the size of the memory gap that will be used between subsequently loaded DOS programs.  This gap serves as a memory reserve.

Some programs compiled with Borland C 5.02 try to increase the size of their program memory block at runtime before, for example, opening a file with Borland C-Library function fopen.   (The programs calls int21h 0x4A.   This happens down inside the C-Library fopen function and is not directly visible to the application programmer.)  

This memory resize call fails if another program has been loaded after the one making the call due to now there is no memory space left for increasing the memory size of the first program.   The program returns from fopen with an error.   The global program variable errno is set to value 8 (not enough memory).   To prevent this error the size of a memory gap between two loaded programs can be controlled.   The value is defined in terms of memory paragraphs (1 paragraph = 16 bytes on SC1x / 256 bytes on SC2x/SC1x3).   This value can also defined in the CHIP.INI file.

This strategy could fail in the cases where programs are terminated and are started again.

It is usually not necessary to set this entry, if the application does not show the described error.  Only if a C-Library function call sets errno to 8, should this value be defined.   We recommend in that case a value of 128 paragraphs for SC1x or 8 paragraphs for SC1x3 (2048 bytes in either case).  

SC1x3/SC2x Comments

The BeckHeap library provides an alternative solution to this memory problem.

RTOS API

This library function invokes a RTOS software interrupt.   Refer to this RTOS API function's documentation for more details.

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3SC2x
    V1.02V1.00V1.00V0.90V1.00

This API List
List of C Libraries
@CHIP-RTOS Main Index


End of document