summaryrefslogtreecommitdiff
path: root/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c
diff options
context:
space:
mode:
Diffstat (limited to 'samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c')
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c b/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c
index 15ee63d3b..88f37504b 100644
--- a/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c
+++ b/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c
@@ -62,12 +62,12 @@ static uint32_t helper_task_iterations = 0;
*/
void yieldingTask(void)
- {
+{
while (helper_task_iterations < NB_OF_YIELD) {
- task_yield();
- helper_task_iterations++;
- }
+ task_yield();
+ helper_task_iterations++;
}
+}
/*******************************************************************************
*
@@ -79,60 +79,60 @@ void yieldingTask(void)
*/
void microTaskSwitchYield(void)
- {
+{
uint32_t iterations = 0;
int32_t delta;
uint32_t timestamp;
PRINT_FORMAT(" 5- Measure average context switch time between tasks using"
- " (task_yield)");
+ " (task_yield)");
bench_test_start();
- /* launch helper task of the same priority than this routine */
+ /* launch helper task of the same priority than this routine */
task_start(YIELDTASK);
- /* get initial timestamp */
+ /* get initial timestamp */
timestamp = TIME_STAMP_DELTA_GET(0);
- /* loop until either helper or this routine reaches number of yields */
+ /* loop until either helper or this routine reaches number of yields */
while (iterations < NB_OF_YIELD && helper_task_iterations < NB_OF_YIELD) {
- task_yield();
- iterations++;
+ task_yield();
+ iterations++;
}
- /* get the number of cycles it took to do the test */
+ /* get the number of cycles it took to do the test */
timestamp = TIME_STAMP_DELTA_GET(timestamp);
- /* Ensure both helper and this routine were context switching back & forth.
- * For execution to reach the line below, either this routine or helper
- * routine reached NB_OF_YIELD. The other loop must be at most one
- * iteration away from reaching NB_OF_YIELD if execute was switching back
- * and forth.
- */
+ /* Ensure both helper and this routine were context switching back & forth.
+ * For execution to reach the line below, either this routine or helper
+ * routine reached NB_OF_YIELD. The other loop must be at most one
+ * iteration away from reaching NB_OF_YIELD if execute was switching back
+ * and forth.
+ */
delta = iterations - helper_task_iterations;
if (bench_test_end() < 0) {
- errorCount++;
- PRINT_OVERFLOW_ERROR();
+ errorCount++;
+ PRINT_OVERFLOW_ERROR();
}
else if (abs(delta) > 1) {
- /* expecting even alternating context switch, seems one routine
- * called yield without the other having chance to execute
- */
- errorCount++;
- PRINT_FORMAT(" Error, iteration:%lu, helper iteration:%lu",
- iterations, helper_task_iterations);
+ /* expecting even alternating context switch, seems one routine
+ * called yield without the other having chance to execute
+ */
+ errorCount++;
+ PRINT_FORMAT(" Error, iteration:%lu, helper iteration:%lu",
+ iterations, helper_task_iterations);
}
else {
- /* task_yield is called (iterations + helper_task_iterations)
- * times in total.
- */
- PRINT_FORMAT(" Average task context switch using "
- "yield %lu tcs = %lu nsec",
- timestamp / (iterations + helper_task_iterations),
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp,
- (iterations + helper_task_iterations)));
- }
+ /* task_yield is called (iterations + helper_task_iterations)
+ * times in total.
+ */
+ PRINT_FORMAT(" Average task context switch using "
+ "yield %lu tcs = %lu nsec",
+ timestamp / (iterations + helper_task_iterations),
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp,
+ (iterations + helper_task_iterations)));
}
+}
#endif