FreeRTOS - long time stability?

grunfalan wrote on Sunday, November 02, 2008:

Hello friends,

For some time now, I am trying to find a good RTOS that I am going to use in my future projects with AVR microcontrollers. FreeRTOS is one of my favorites now, but as I don’t have any experience with RTOS, some questions started to emerge.

I found information (on SafeRTOS FAQ) that SafeRTOS uses static memory allocation for RTOS data instead of dynamic, which is used in FreeRTOS - and therefore it is more safe and stable.

Also, on this forum, somebody mentioned memory leakage, as if it is something usual and inevitable with FreeRTOS.

Does it mean that application with FreeRTOS can not be made for long time stability and 24/7/365 work? If that’s the case, could it be avoided with some careful programming technique? How big is this problem in practice?

I want to use it in a device that is placed on distance location, and should work for a long time without "freezing".
I already built the device without RTOS (foreground/background system), and it works very stable on several locations, but now I am considering using RTOS because of easier upgrade/mantaining.

Does use of FreeRTOS increase possibility of fallouts?

As I said, I am a complete newbie concerning RTOS, and any comment or experience will be valuable to me.


richard_damon wrote on Sunday, November 02, 2008:

I suppose it depend what you do. From my inspection of the code, the only dynamic memory that is used is for the creation of tasks, queue and related objects. If you program creates all of these that are needed at start up, then the dynamic nature of the allocation isn’t an issue for long term operation.

rtel wrote on Sunday, November 02, 2008:

This is correct - memory is required each time a task, queue or semaphore is created, and freed when the same task/queue/semaphore is deleted. 

In the memory is obtained from the [pseudo] heap, whereas in SafeRTOS the memory is provided by the application.  Although the SafeRTOS application is free to obtain this memory in any way it wants, in a safety critical application normally only statically declared buffers would be used as generally dynamic allocation has problems regarding non-deterministic allocation/free times and with fragmentation (memory pools can be used to fix some of these issues but these are complex to use and tune, so are not safer).

If you never delete a task, queue or semaphore then memory is never freed so you have no issues to worry about in that regard.  Also the schemes used in are very simplistic, and the way memory is allocated so restricted, that generally you would not have any problems in any case.  The one thing to watch out for in is that you always allow the idle task some processing time if you are wanting to delete resources as it is the idle task that does the final clean up.  Also, never write an application that uses dynamic memory allocation to allocate and free ‘random’ sized blocks as this is where you can get into fragmentation problems - but this is true for any embedded system be it based or not.


grunfalan wrote on Monday, November 03, 2008:

Thanks, very much, to both of you!

That is exactly the answer that I was hoping for.

I already started to play with simple tasks.
It is very exciting - I cant wait to try all the options… Solves easy much of the problems that I have had before…