@CHIP-RTOS C Library - BeckHeap Optional Library

    IPC@CHIP® Documentation Index

BeckHeap Library

This library applies only to the SC1x3/SC2x targets. It will not work on the SC1x target systems.

The BeckHeap library provides a multi-tasking alternate heap implementation for the application program's far heap.   All functions are re-entrant and thread safe.

This far heap implementation has two primary advantages over the Pardigm-Beck standard Run-Time Library (RTL) far heap wrapped with the heap.c source file.
  1. Less overhead per allocated block.
  2. Provides a solution to the MEMGAP problem.
The disadvantage over the standard RTL far heap implementation is that this implementation will be slightly slower than the RTL's far heap. This is due to that this BeckHeap is managed with 32 bit far pointers instead of the 16 bit segment pointers used by the RTL heap.   But with the SC1x3/SC2x computer's 256 byte paragraphs, this fast RTL implementation will waste a lot of memory when a program allocates a large number of objects in the far heap.   At each alllocation, an extra ~240 bytes is lost at the round off to the next segment.   (Back in the old DOS computer days, with 16 byte paragraph size, this round off was not an issue.)

The memory gap problem, encountered when the RTL far heap could not grow due to a subseqeuent application program occupying the system memory following your program, is solved by using multiple "heap regions".   Each heap region managed by the BeckHeap is essentially (software wise) an independent heap.   So this far heap is implemented using a collection of heaps which may be scattered around the @CHIP-RTOS system memory.   This implementation is then hidden so that these multiple heaps appear to the application programmer as a single far heap.

Neither of these two problems exists for the RTL near heap, used by the SMALL or MEDIUM memory models.   So the heap.c source file is sufficient for protecting the near heap for multi-tasking access.   The BeckHeap library applies only to the far heap.   SMALL or MEDIUM memory model programs may use the BeckHeap library for their far heap.

For COMPACT, LARGE and HUGE memory models the "far heap" is the one and only heap within the program.   The only difference between farmalloc() and malloc() in these cases is the amount of memory which can be allocated by the call.

A set of debug functions is provided to assist with tracking down dynamic memory problems.

One of the following libraries must be selected based on your program's memory model, and included in your project when this alternative heap is desired.
  • BeckHeapS.LIB - Small memory model
  • BeckHeapM.LIB - Medium memory model (small data)
  • BeckHeapC.LIB - Compact memory model (small program)
  • BeckHeapL.LIB - Large memory model
  • BeckHeapH.LIB - Huge memory model

For performance reasons, it is recommended that you use the optional HugePtr library when ever the BeckHeap library is used. The HugePtr library provides very fast huge pointer arithmetic for internal use by the C compiler.

End of document