1 / 4

Memory Management

Memory Management. Akos Ledeczi EECE 354, Fall 2011 Vanderbilt University. 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

lindsey
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

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

More Related