SlideServe
Menu
Preferences
© SlideServe · v2026

Memory Management

lindsey avatar
4 slides · 193 Views · 40 likes · Sep 05, 2014

This document explores memory management strategies in µC/OS-III, focusing on dynamic memory allocation and the challenges of fragmentation with traditional heap allocation via `malloc()` and `free()`. It emphasizes the advantages of memory partitions, allowing the creation of multiple partitions with varied block sizes for efficient memory usage. An example demonstrates how to create a memory partition and use it to allocate and deallocate blocks safely, highlighting the importance of ensuring data integrity through proper synchronization techniques like semaphores.

Memory Management - slide 1
01 / 4Memory Management
1 / 17

Download Presentation

Memory Management
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

More Related Content

Presentation Transcript
  1. Memory Management Akos Ledeczi EECE 354, Fall 2011 Vanderbilt University

  2. Memory Partitions • Dynamic memory allocation from the heap /malloc() and free()/ can lead to memory fragmentation • µC/OS-III provides memory partitions as an alternative • Can create multiple partitions with different block sizes

  3. Usage OS_MEM MyPartition; CPU_INT08U Storage[12][100]; /* malloc() also works */ void main() { … OSMemCreate(&MyPartition, “My partition”, (void *)&Storage[0][0], 12,100, &err); … } void MyTask(void *p_arg) { … CPU_INT08U *block = (CPU_INT08U *)OSMemGet(&MyPartition,&err); /* allocate */ if (err == OS_ERR_NONE) { … } … OSMemPut(&MyPartition,block,&err); /* deallocate */ … }

  4. Example • Memory block is not typed: reader and write “agrees” on the content’s format • Once message is written and posted in the queue, originator must not touch it • Once message received and processed, memory block is put back in the partition • To prevent problems if partition runs out of available blocks, a semaphore can be used to control access to it