Quality RTOS & Embedded Software

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




Loading

Queue and Memory Management functions

Posted by iporboon on April 11, 2011
Hello

I use the queue functions of freertos to pass the messages among the tasks in the real-time systems. My messages are the groups of data such as arrays or structures. I have to create the queues with the message size of array or structure.

It seems to consume a lot of RAM from my systems. I can not send the pointers to the queues because there is not the dynamic mem alloc in freertos API to use to store the arrays or structures, and I do not want to use malloc function from standard C library because of the real-time predictability problem of that function.

Please suggest the solutions of my problem.
Thank you very much.

RE: Queue and Memory Management functions

Posted by Richard on April 11, 2011
Normally, if you are sending large items of data, you would queue a pointer to the data and the application would have to ensure the data was access correctly (only one task has responsibility for changing the data, only one task for marking the buffer free again once the data is read, etc.).

If you want to send different items on a single queue, then the normal way is to send structures on the queue, with one of the structure members indicating what the queued item actually is, so the receiving task knows how to handle the data.

Regards.

RE: Queue and Memory Management functions

Posted by iporboon on April 11, 2011
I am very sorry if my problem was not clear.

I can not send the pointers to queue because there is not the dynamic mem alloc in freertos API, so I can not get mem blocks to store the data and I do not want to use malloc function of standard C library because of the real-time predictivity problem of that function.

Best regards.

RE: Queue and Memory Management functions

Posted by Dave on April 11, 2011
If your blocks are always the same size then you can use heap_2.c as a dynamic memory allocator without fear of fragmentation. Otherwise, can you use statically declared memory blocks?

RE: Queue and Memory Management functions

Posted by Stephen Cleary on April 11, 2011
If your blocks are the same size, then you can write a very simple pool allocator.

Otherwise, you can write your own (deterministic) memory allocator. I have implemented a modified version of TLSF, and it works quite well so far.


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




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS