Understanding Memory Management in Operating Systems Today's video focuses on understanding memory management within operating systems. Many users don't grasp how the linker places variables in RAM or flash memory of a microcontroller, leading to misconceptions about resource consumption by the OS.
Static vs Dynamic Memory Allocation Models From version FRS 9 onwards, two models for kernel object placement are available: static (during compilation) and dynamic (at runtime). Each model has its pros and cons; personal experience shows no issues with dynamic allocation despite long-term use.
Memory Allocation Concepts Beyond RTOS Contexts Memory allocation is a general programming concept not unique to RTOS or multitasking. Standard functions like malloc/free have limitations such as fragmentation risks and non-thread safety, making them less ideal for real-time applications.
'Heap_1' Model: Simple Static Array-Based Allocation 'Heap_1' uses a statically allocated array defined at compile time without freeing up space once allocated. This simple approach avoids fragmentation but lacks flexibility needed for tasks requiring temporary buffers.
'Heap_2': An Outdated Fragmentation-Prone Model 'Heap_2', though capable of allocating and freeing memory dynamically from an array, cannot defragment it efficiently. It’s included mainly for backward compatibility with older projects but isn't recommended due to potential inefficiencies.