/********************************************************************* * * LPTask */ static void LPTask(void) { while (1) { OS_Delay(100); // Syncronize to tick to avoid jitter // // Display measurement overhead // BSP_SetLED(0); BSP_ClrLED(0); // // Perform measurement // BSP_SetLED(0); // Start measurement OS_Resume(&TCBHP); // Resume high priority task to force task switch } }
void MainTask(void) { OS_CREATETASK(&TCBHP, "HP Task", HPTask, 150, StackHP); OS_Delay(1); while (1) { OS_Delay(100); // Syncronize to tick to avoid jitter // // Display measurement overhead // BSP_SetLED(0); BSP_ClrLED(0); // // Perform measurement // BSP_SetLED(0); // Start measurement OS_Resume(&TCBHP); // Resume high priority task to force task switch } }
void MENU_OP_Task(void) { char func_index,event ; OS_CREATEMB(&MBFunc,1,sizeof(MBFuncBuffer),&MBFuncBuffer) ; for(;;) { OS_WaitMail(&MBFunc) ; OS_GetMail1(&MBFunc, &event) ; if(event&EVENT_OP_STARTED) { OS_GetMail1(&MBFunc, &func_index) ; Item_OP[func_index](&func_index) ; if(OS_GetSuspendCnt(&LCD_TASK_TCB)) OS_Resume(&LCD_TASK_TCB) ; } } }
void MainTask(void) { OS_U32 MeasureOverhead; // Time for Measure Overhead OS_U32 v; // Real context switch time OS_CREATETASK(&TCBHP, "HP Task", HPTask, 150, StackHP); OS_Delay(1); // // Measure Overhead for time measurement so we can take this into account by subtracting it // OS_Timing_Start(&MeasureOverhead); OS_Timing_End(&MeasureOverhead); // // Perform measurements in endless loop // while (1) { OS_Delay(100); // Syncronize to tick to avoid jitter OS_Timing_Start(&_Time); // Start measurement OS_Resume(&TCBHP); // Resume high priority task to force task switch v = OS_Timing_GetCycles(&_Time) - OS_Timing_GetCycles(&MeasureOverhead); // Calculate real context switch time (w/o measurement overhead) v = OS_ConvertCycles2us(1000 * v); // Convert cycles to nano-seconds, increase time resolution printf("Context switch time: %u.%.3u usec\r\n", v / 1000, v % 1000); // Print out result } }