Download presentation
Presentation is loading. Please wait.
Published byBenny Indradjaja Modified over 6 years ago
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.