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] [July 2015 Threads] Dynamic allocation malloc() or pvPortMalloc() is safe?Posted by jeemon on July 21, 2015 Hi,
Which is more safe to use in an application developed using FREERTOS? pvPortMalloc() or malloc()?
I used dynamic allocation (malloc()) to allocate memory and the code execution gone to hard fault handler. Instead, when I used pvPortMalloc() of heap2, it worked well even without increasing its task's stack memory. Also malloc() is well defined in my code(I have used it before).
Thanks in Advance
Jeemon Joy
Dynamic allocation malloc() or pvPortMalloc() is safe?Posted by rtel on July 21, 2015 The following page contains relevant comments: http://www.freertos.org/a00111.html
Dynamic allocation malloc() or pvPortMalloc() is safe?Posted by richard_damon on July 22, 2015 One key thing to remember is that parts of the library (especially things like malloc/free) may not be thread safe, and these can cause issues if you don't protect them. Any function that uses local statics or globals (like the heap), can have problems. Some libraries have hooks in them to let you make them thread safe (giving them thread local storage or a mutex to protect themselves), but I am not sure if FreeRTOS has implemented those hooks in its port layer in many cases. Many other cases you have to add this as a wrapper (like heap3.c does).
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|