Presentation is loading. Please wait.

Presentation is loading. Please wait.

Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University

Similar presentations


Presentation on theme: "Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University"— Presentation transcript:

1 Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Memory Management Akos Ledeczi EECE 6354, Fall 2017 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


Download ppt "Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University"

Similar presentations


Ads by Google