IAR PowerPac RTOS User Guide
IAR PowerPac RTOS User Guide IAR PowerPac RTOS User Guide
The following table gives an overview about the variations of the context switch time depending on the memory typeand the CPU mode:Target OS version Memory CPU mode TimeATMEL AT91SAM7S256 3.32p Flash Thumb 8.92 usATMEL AT91SAM7S256 3.32p Flash ARM 9.32 usATMEL AT91SAM7S256 3.32p RAM ARM 6.28 usATMEL AT91SAM7S256 3.32p RAM Thumb 7.12 usTable 130: embOS context switch timesAll example performance values in the following section are determined with the following system configuration:ATMEL AT91SAM7S256 running with 48 MHz clock speed. All sources are compiled with IAR EmbeddedWorkbench version 4.41A using Thumb mode with high optimization level. The example program executes in of flashmemory.MEASUREMENT WITH PORT PINS AND OSCILLOSCOPEThe example file MeasureCST_Scope.c uses the LED.c module to set and clear a port pin. This allows measuringthe context switch time with an oscilloscope.The following source code is excerpt from MeasureContextSwitchingTime_Scope.c:#include "RTOS.h"#include "LED.h"static OS_STACKPTR int StackHP[128], StackLP[128]; // Task stacksstatic OS_TASK TCBHP, TCBLP;// Task-control-blocks/*********************************************************************** HPTask*/static void HPTask(void) {while (1) {OS_Suspend(NULL); // Suspend high priority taskLED_ClrLED0(); // Stop measurement}}/*********************************************************************** LPTask*/static void LPTask(void) {while (1) {OS_Delay(100); // Syncronize to tick to avoid jitter//// Display measurement overhead//LED_SetLED0();LED_ClrLED0();//// Perform measurement//LED_SetLED0(); // Start measurementOS_Resume(&TCBHP); // Resume high priority task to force task switch}}/*********************************************************************** main*/int main(void) {OS_IncDI();// Initially disable interruptsOS_InitKern();// Initialize OSOS_InitHW();// Initialize Hardware for OSLED_Init();// Initialize LED portsOS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);OS_CREATETASK(&TCBLP, "LP Task", LPTask, 99, StackLP);OS_Start();// Start multitaskingreturn 0;}128IAR PowerPac RTOSfor ARM CoresPPRTOS-2
Performance and resource usageThe context switch time is the time between switching the LED on and off. If the LED is switched on with an activehigh signal, the context switch time is the time between rising and falling edge of the signal. If the LED is switched onwith an active low signal, the signal polarity is reversed.The real context switch time is shorter, because the signal also contains the overhead of switching the LED on and off.The time of this overhead is also displayed on the oscilloscope as a small peak right before the task switch time displayand has to be subtracted from the displayed context switch time.The following oscilloscope screenshots show the output of the MeasureContextSwitchingTime_Scope.cexample running on an AT91SAM7S256 processor with 48MHz clock speed.The small peak in the screenshot below shows the overhead which has to be subtracted from the context switch time.The time between the first falling edge and the first rising edge is the measurement overhead, in the example screenshotT1 = 320 ns.PPRTOS-2129
- 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 and 88: Event objectsExampleOS_EVENT_Reset(
- Page 89 and 90: Heap type memory managementANSI C o
- 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: Performance and resource usageThis
- 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
- Page 139 and 140: Additional modulesKeyboard manager:
- Page 141 and 142: FAQ (frequently asked questions)Q:
- Page 143 and 144: GlossaryActive TaskCooperativemulti
- Page 145 and 146: IndexIndexAAdditional modules . . .
- Page 147: IndexOS_WaitSingleEventTimed(). . .
Performance and resource usageThe context switch time is the time between switching the LED on and off. If the LED is switched on with an activehigh signal, the context switch time is the time between rising and falling edge of the signal. If the LED is switched onwith an active low signal, the signal polarity is reversed.The real context switch time is shorter, because the signal also contains the overhead of switching the LED on and off.The time of this overhead is also displayed on the oscilloscope as a small peak right before the task switch time displayand has to be subtracted from the displayed context switch time.The following oscilloscope screenshots show the output of the MeasureContextSwitchingTime_Scope.cexample running on an AT91SAM7S256 processor with 48MHz clock speed.The small peak in the screenshot below shows the overhead which has to be subtracted from the context switch time.The time between the first falling edge and the first rising edge is the measurement overhead, in the example screenshotT1 = 320 ns.PP<strong>RTOS</strong>-2129