IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide IAR PowerPac RTOS User Guide

ie.ksu.edu.tw
from ie.ksu.edu.tw More from this publisher
11.07.2015 Views

●no tasks are waiting at the event object when it is deleted.pEvent has to address an existing event object, which has been created before by a call of OS_EVENT_Create().The debug version of IAR PowerPac RTOS will check whether pEvent addresses a valid event object and will callOS_Error() with error code OS_ERR_EVENT_INVALID in case of an error. If any task is waiting at the eventobject which is deleted, the debug version of IAR PowerPac RTOS calls OS_Error() with error codeOS_ERR_EVENT_DELETE. To avoid any problems, an event object should not be deleted in a normal application.88IAR PowerPac RTOSfor ARM CoresPPRTOS-2

Heap type memory managementANSI C offers some basic dynamic memory management functions. These are malloc, free, and realloc.Unfortunately, these routines are not thread-safe, unless a special thread-safe implementation exists in the compilerspecific runtime libraries; they can only be used from one task or by multiple tasks if they are called sequentially.Therefore, IAR PowerPac RTOS offer task-safe variants of these routines. These variants have the same names as theirANSI counterparts, but are prefixed OS_; they are called OS_malloc(), OS_free(), OS_realloc(). The threadsafevariants that IAR PowerPac RTOS offers use the standard ANSI routines, but they guarantee that the calls areserialized using a resource semaphore.Heap type memory management is part of the IAR PowerPac RTOS libraries. It does not use any resources if it is notreferenced by the application (that is, if the application does not use any memory management API function).Note that another aspect of these routines may still be a problem: the memory used for the functions (known as heap)may fragment. This can lead to a situation where the total amount of memory is sufficient, but there is not enoughmemory available in a single block to satisfy an allocation request.Heap type memory manager API referenceAPI routineDescriptionOS_malloc() Allocates a block of memory on the heap.OS_free()Frees a block of memory previously allocated.OS_realloc() Changes allocation size.Table 98: Heap type memory manager API overviewPPRTOS-2 89

Heap type memory managementANSI C offers some basic dynamic memory management functions. These are malloc, free, and realloc.Unfortunately, these routines are not thread-safe, unless a special thread-safe implementation exists in the compilerspecific runtime libraries; they can only be used from one task or by multiple tasks if they are called sequentially.Therefore, <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> offer task-safe variants of these routines. These variants have the same names as theirANSI counterparts, but are prefixed OS_; they are called OS_malloc(), OS_free(), OS_realloc(). The threadsafevariants that <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> offers use the standard ANSI routines, but they guarantee that the calls areserialized using a resource semaphore.Heap type memory management is part of the <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> libraries. It does not use any resources if it is notreferenced by the application (that is, if the application does not use any memory management API function).Note that another aspect of these routines may still be a problem: the memory used for the functions (known as heap)may fragment. This can lead to a situation where the total amount of memory is sufficient, but there is not enoughmemory available in a single block to satisfy an allocation request.Heap type memory manager API referenceAPI routineDescriptionOS_malloc() Allocates a block of memory on the heap.OS_free()Frees a block of memory previously allocated.OS_realloc() Changes allocation size.Table 98: Heap type memory manager API overviewPP<strong>RTOS</strong>-2 89

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!