Queue and Memory Management functions

iporboon wrote on Monday, 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.

rtel wrote on Monday, 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.

iporboon wrote on Monday, 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.

davedoors wrote on Monday, 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?

stephencleary wrote on Monday, 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.