User`s guide
48
K
A
DAK
KwikNet System Configuration
OS Parameters (continued)
Source and Size of Memory Region (Heap)
If you use the KwikNet simple heap or operating system memory services which require a
private region of memory for use as a heap, then you must provide that memory. From
the pull down list, choose the method to be used to allocate such a memory region for use
by the memory allocator.
If you choose the Static array option, you must enter the array size (in bytes) in the
Region size field. A character array of that size will be declared in the KwikNet Library.
KwikNet will allocate memory from that array.
If you choose the
malloc() option, use the Region size field to define the number of bytes
to be allocated for use as a heap. During
KwikNet's startup initialization, the KwikNet Task
will call C library function
malloc() once to allocate a memory block of the specified
size.
KwikNet will subsequently allocate memory from that single block.
An alternate approach is to choose the User function option and provide a function called
kn_msmemacquire() which is prototyped as shown below. The Region size field is
passed to your function as parameter memsize. When KwikNet starts up, it will call the
function to get the size of your memory region and a pointer to it. The function must
install a pointer to a block of n bytes of memory into *mempp and return the value n where
n is greater than or equal to memsize.
unsigned long kn_msmemacquire(char **mempp, unsigned long memsize);
Protect Memory Get/Free Operations
When operating in a multitasking environment, the memory allocation services must be
thread-safe. If the memory allocation services you have chosen to use are not thread-
safe, check the box labeled "Need memory lock" and KwikNet will use its memory locking
mechanism to protect access to memory. Otherwise, leave this box unchecked.
If you are using the AMX kernel and either the
KwikNet simple heap or the AMX Memory
Manager with a private heap, then memory allocation services are inherently thread-safe.
Hence, leave this box unchecked.
If you are using
KwikNet with AMX and using standard C for memory allocation you
must check this box, unless your C library is inherently thread-safe.
When operating in a single threaded environment, memory allocation services are
inherently thread-safe. Hence, leave this box unchecked.