Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Memory manager for IAR, KEIL and others ...

Posted by Jaroslav Fojtik on February 10, 2013
This memory manager can reuse standard C-lib functions. Sometimes the malloc, realloc and free could be optimized more precise in C lib than those proposed in RTOS..

FreeRTOS\Source\portable\MemMang\HeapClib.c:
#include 

#include "FreeRTOS.h"
#include "task.h"


void vPortFree( void *pv )
{
if(pv)
{
vTaskSuspendAll();
free(pv);
xTaskResumeAll();
}
}

void *pvPortMalloc(size_t xWantedSize)
{
void *Mem;
vTaskSuspendAll();
Mem = malloc(xWantedSize);
xTaskResumeAll();
return (Mem);
}

RE: Memory manager for IAR, KEIL and others ...

Posted by Richard on February 11, 2013
What is the difference between this and heap_3.c?

Heap_4.c is currently the preferred scheme if RAM is going to be freed as well as allocated.

Regards.

RE: Memory manager for IAR, KEIL and others ...

Posted by Jaroslav Fojtik on February 11, 2013
Sorry, I overlook that. Anyway, this memory scheme performs a little better in Keil. You can use safelly malloc and free inside your code and everything is synchronized. Keil can use in its C-lib externally provided mutex.

void vPortFree( void *pv )
{
free(pv);
}

void *pvPortMalloc(size_t xWantedSize)
{
return malloc(xWantedSize);
}


/*--------------------------- _mutex_initialize -----------------------------*/
int _mutex_initialize (_SYNC_t *mutex)
{
/* Allocate and initialize a system mutex. */
vSemaphoreCreateBinary(*mutex);/*Create semaphore*/
return (1);
}


/*--------------------------- _mutex_acquire --------------------------------*/

__attribute__((used)) void _mutex_acquire(_SYNC_t *mutex)
{
/* Acquire a system mutex, lock stdlib resources. */
if(RTOS_STATE == RTOS_RUNNING)
{ /* RTX running, acquire a mutex. */
xSemaphoreTake(*mutex, 500);
}
}


/*--------------------------- _mutex_release --------------------------------*/

__attribute__((used)) void _mutex_release (_SYNC_t *mutex)
{
/* Release a system mutex, unlock stdlib resources. */
if(RTOS_STATE == RTOS_RUNNING)
{ /* RTX runnning, release a mutex. */
xSemaphoreGive(*mutex);
}
}

//http://www.keil.com/forum/16315/


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists