Memory usage can be minimized by limiting the number of RTOS objects that are created during run-time.
6. Optimize the Task Stacks
Task stacks are notorious for consuming the most memory in an application. Many developers just guess at a value rather than making a measurement. Many RTOSes will recommend a default stack size around 1 kB for a task. Is that too much? Too little? There is no way to tell without making a measurement so a developer will just guess. The result is way too much memory being allocated for stack space and wasted. Developers should utilize stack monitoring features associated with the RTOS to determine their min, max, and average stack usage. From the maximum, adding an extra 25% would be a safe rule of thumb to size the stack.
7. Turn Off Unused Features
RTOSes are extremely rich and complicated software systems. They include many features that won’t be utilized by every application or developer. Becoming familiar with the RTOSes configuration file can be very helpful in minimizing memory usage and code size. The configuration file allows developers to enable and disable features.
Using an RTOS doesn’t necessarily require a souped-up microcontroller or a plethora of memory. The way that a developer architects and uses their RTOS can make all the difference between whether it works well in a resource-constrained environment or is labeled bloat code. These seven tips are just a few to get you started in optimizing your RTOS.
What other tips can you think of to make sure that an RTOS runs efficiently in a small memory footprint? Share your ideas in the below comments section.
Jacob Beningo is an embedded software consultant who currently works with clients in more than a dozen countries to dramatically transform their businesses by improving product quality, cost and time to market. He has published more than 200 articles on embedded software development techniques, is a sought-after speaker and technical trainer and holds three degrees which include a Masters of Engineering from the University of Michigan. Feel free to contact him at [email protected], at his website www.beningo.com/, and sign-up for his monthly Embedded Bytes Newsletter .