IAR PowerPac RTOS User Guide
IAR PowerPac RTOS User Guide IAR PowerPac RTOS User Guide
●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
- Page 37 and 38: Software timersSoftware timerA soft
- Page 39 and 40: Software timers#define OS_CREATETIM
- Page 41 and 42: Software timersOS_SetTimerPeriod()D
- Page 43 and 44: Software timersAdditional Informati
- Page 45 and 46: Software timersAdditional Informati
- Page 47 and 48: Software timersExampleOS_TIMER TIME
- Page 49 and 50: Resource semaphoresIntroductionReso
- Page 51 and 52: Resource semaphoresResource semapho
- Page 53 and 54: Resource semaphoresOS_Request()Desc
- Page 55 and 56: Counting SemaphoresIntroductionCoun
- Page 57 and 58: Counting SemaphoresPrototypevoid OS
- Page 59 and 60: Counting SemaphoresReturn value0: I
- Page 61 and 62: MailboxesWhy mailboxes?In the prece
- Page 63 and 64: MailboxesMailboxes API function ove
- Page 65 and 66: MailboxesExampleSingle-byte mailbox
- Page 67 and 68: MailboxesPrototypevoid OS_GetMail (
- Page 69 and 70: MailboxesOS_WaitMail()DescriptionWa
- Page 71 and 72: QueuesWhy queues?In the preceding c
- Page 73 and 74: QueuesReturn valueThe size of the r
- Page 75 and 76: QueuesExamplestatic void MemoryTask
- Page 77 and 78: Task eventsIntroductionTask events
- Page 79 and 80: Task eventsExampleOS_WaitEventTimed
- Page 81 and 82: Task eventsPrototypechar OS_ClearEv
- Page 83 and 84: Event objectsIntroductionEvent obje
- Page 85 and 86: Event objectsExampleif (OS_EVENT_Wa
- Page 87: Event objectsExampleOS_EVENT_Reset(
- Page 91 and 92: Fixed block size memory poolsIntrod
- Page 93 and 94: Fixed block size memory poolsProtot
- Page 95 and 96: Fixed block size memory poolsProtot
- Page 97 and 98: StacksIntroductionThe stack is the
- Page 99 and 100: InterruptsIntroductionIn this chapt
- Page 101 and 102: InterruptsRules for interrupt handl
- Page 103 and 104: InterruptsOS_LeaveInterruptNoSwitch
- Page 105 and 106: InterruptsNesting interrupt routine
- Page 107 and 108: Critical RegionsIntroductionCritica
- Page 109 and 110: System variablesIntroductionThe sys
- Page 111 and 112: Configuration for your targetsystem
- Page 113 and 114: Time measurementIntroductionIAR Pow
- Page 115 and 116: Time measurementPrototypeU32 OS_Get
- Page 117 and 118: Time measurementPrototypeOS_U32 OS_
- Page 119 and 120: RTOS-aware debuggingThis chapter de
- Page 121 and 122: RTOS-aware debuggingTimersA softwar
- Page 123 and 124: DebuggingRuntime errorsSome error c
- Page 125 and 126: DebuggingValue Define Description17
- Page 127 and 128: Performance and resource usageThis
- Page 129 and 130: Performance and resource usageThe c
- Page 131 and 132: Performance and resource usage*/sta
- Page 133 and 134: ReentranceAll routines that can be
- Page 135 and 136: LimitationsThe following limitation
- Page 137 and 138: Source code of kernel and libraryIn
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