FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [February 2013 Threads] 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/
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|