Universal Startup API for RTOSes
Malloc Initialization Interface
int init_minigui_malloc (unsigned char* heap, unsigned int heap_size,
int (*lock_heap) (void), int (*unlock_heap) (void));#include "tx_api.h"
/* use a static array as the heap */
#define HEAPSIZE (1024*1024*3)
static unsigned char __threadx_heap [HEAPSIZE];
static unsigned int __threadx_heap_size = HEAPSIZE;
static TX_MUTEX __threadx_malloc_mutex;
#define NAME_MUTEX_MALLOC "Mutex4Malloc"
static int __threadx_heap_lock (void)
{
UINT status;
status = tx_mutex_get (&__threadx_malloc_mutex, TX_WAIT_FOREVER);
if (status == TX_SUCCESS)
return 0;
return -1;
}
static int __threadx_heap_unlock (void)
{
UINT status;
status = tx_mutex_put (&__threadx_malloc_mutex);
if (status == TX_SUCCESS)
return 0;
return -1;
}
...
/*
* Initialize MiniGUI's heap memory management module secondly.
*/
if (tx_mutex_create (&__threadx_malloc_mutex, NAME_MUTEX_MALLOC, TX_NO_INHERIT) = TX_SUCCESS) {
fprintf (stderr, "Can not init mutex object for heap.\n");
return;
}
if (init_minigui_malloc (__threadx_heap, __threadx_heap_size, __threadx_heap_lock, __threadx_heap_unlock)) {
fprintf (stderr, "Can not init MiniGUI heap system.\n");
return;
}
Standard Output Initialization Interface
POSIX Threads Initialization Interface
Last updated