From e9b60a2013576bf0060c919298739f44c76544a7 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez Pedraza" Date: Thu, 29 Aug 2024 13:50:07 -0400 Subject: [PATCH] Fix #2592, Only yield CPU once every 1024 messages --- .../cfe_testcase/src/sb_performance_test.c | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/modules/cfe_testcase/src/sb_performance_test.c b/modules/cfe_testcase/src/sb_performance_test.c index df64dfc25..4716a88fc 100644 --- a/modules/cfe_testcase/src/sb_performance_test.c +++ b/modules/cfe_testcase/src/sb_performance_test.c @@ -37,6 +37,9 @@ /* Number of messages to send during test */ uint32_t UT_BulkTestDuration = 1000; +/* Number of SB messages sent before yielding CPU (has to be power of 2 minus 1)*/ +uint32_t UT_CpuYieldMask = 1024 - 1; + /* State structure for multicore test - shared between threads */ typedef struct UT_BulkMultiCoreSharedState { @@ -210,8 +213,12 @@ void RunSingleCmdSendRecv(void) break; } - /* Yield cpu to other task with same priority */ - OS_TaskDelay(0); + /* Only yield CPU once in a while to avoid slowing down the test with too many context switches */ + if ((BulkCmd.SendCount & UT_CpuYieldMask) == 0) + { + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); + } } CFE_PSP_GetTime(&BulkCmd.EndTime); @@ -259,8 +266,12 @@ void RunSingleTlmSendRecv(void) break; } - /* Yield cpu to other task with same priority */ - OS_TaskDelay(0); + /* Only yield CPU once in a while to avoid slowing down the test with too many context switches */ + if ((BulkTlm.SendCount & UT_CpuYieldMask) == 0) + { + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); + } } CFE_PSP_GetTime(&BulkTlm.EndTime); @@ -395,8 +406,12 @@ void UT_CommandTransmitterTask(void) break; } - /* Yield cpu to other task with same priority */ - OS_TaskDelay(0); + /* Only yield CPU once in a while to avoid slowing down the test with too many context switches */ + if ((BulkCmd.SendCount & UT_CpuYieldMask) == 0) + { + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); + } } BulkCmd.XmitFinished = true; @@ -434,8 +449,12 @@ void UT_TelemetryTransmitterTask(void) break; } - /* Yield cpu to other task with same priority */ - OS_TaskDelay(0); + /* Only yield CPU once in a while to avoid slowing down the test with too many context switches */ + if ((BulkTlm.SendCount & UT_CpuYieldMask) == 0) + { + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); + } } BulkTlm.XmitFinished = true;