From the course: IoT Foundations: Operating Systems Fundamentals
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Memory allocation algorithms
From the course: IoT Foundations: Operating Systems Fundamentals
Memory allocation algorithms
- [Instructor] The heap memory used for OS can be used for dynamic memory allocation for objects that are created in runtime. How do dynamic allocation for different objects are allocated? This is the matter of memory allocation algorithms. There are several classical algorithms for memory allocation, each with its own advantages and disadvantages. FreeRTOS offers five example memory allocation options called heap_1 one to heap_5 They may be used as examples to implement custom memory allocation algorithms. Let's take a look. Heap_1 only implements the basic pvPortMalloc API function, so applications that don't delete tasks or kernel objects can use this option. Heap_2 has been replaced by heap_4 because it doesn't merge adjacent free blocks into a larger one. Heap_3 just uses the standard malloc and the free functions for heap management. Heap_2, 4, and 5 all use the First Fit algorithm for memory allocation. Heap_4 manages memory with a single array, while heap_5 supports combining…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.