From 8826b1f69567fc2a675037f70b70c13f554fd599 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez Pedraza" Date: Wed, 14 Aug 2024 17:14:31 -0400 Subject: [PATCH 1/3] Fix #2592, Yield cpu to let other task run This avoids the timeout on SB receives for the receiver tasks --- modules/cfe_testcase/src/sb_performance_test.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/cfe_testcase/src/sb_performance_test.c b/modules/cfe_testcase/src/sb_performance_test.c index fc3135543..bbdbe0c64 100644 --- a/modules/cfe_testcase/src/sb_performance_test.c +++ b/modules/cfe_testcase/src/sb_performance_test.c @@ -209,6 +209,9 @@ void RunSingleCmdSendRecv(void) UtAssert_UINT32_EQ(CmdPtr->Payload.Value, CmdMsg.Payload.Value); break; } + + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); } CFE_PSP_GetTime(&BulkCmd.EndTime); @@ -255,6 +258,9 @@ void RunSingleTlmSendRecv(void) UtAssert_UINT32_EQ(TlmPtr->Payload.Value, TlmMsg.Payload.Value); break; } + + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); } CFE_PSP_GetTime(&BulkTlm.EndTime); @@ -388,6 +394,9 @@ void UT_CommandTransmitterTask(void) CFE_Assert_STATUS_MUST_BE(CFE_SUCCESS); break; } + + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); } BulkCmd.XmitFinished = true; @@ -424,6 +433,9 @@ void UT_TelemtryTransmitterTask(void) CFE_Assert_STATUS_MUST_BE(CFE_SUCCESS); break; } + + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); } BulkTlm.XmitFinished = true; From 9443adb55388dccaf31a239ff380975d70df42a7 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez Pedraza" Date: Thu, 15 Aug 2024 08:51:06 -0400 Subject: [PATCH 2/3] Fix #2592, typo fix --- modules/cfe_testcase/src/sb_performance_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/cfe_testcase/src/sb_performance_test.c b/modules/cfe_testcase/src/sb_performance_test.c index bbdbe0c64..df64dfc25 100644 --- a/modules/cfe_testcase/src/sb_performance_test.c +++ b/modules/cfe_testcase/src/sb_performance_test.c @@ -402,7 +402,7 @@ void UT_CommandTransmitterTask(void) BulkCmd.XmitFinished = true; } -void UT_TelemtryTransmitterTask(void) +void UT_TelemetryTransmitterTask(void) { CFE_SB_Buffer_t * BufPtr; CFE_TEST_TestTlmMessage32_t *TlmMsgPtr; @@ -533,7 +533,7 @@ void TestBulkTransferMulti4(void) CFE_ES_CreateChildTask(&BulkCmd.TaskIdXmit, "CmdXmit", UT_CommandTransmitterTask, NULL, 32768, 150, 0), CFE_SUCCESS); UtAssert_INT32_EQ( - CFE_ES_CreateChildTask(&BulkTlm.TaskIdXmit, "TlmXmit", UT_TelemtryTransmitterTask, NULL, 32768, 150, 0), + CFE_ES_CreateChildTask(&BulkTlm.TaskIdXmit, "TlmXmit", UT_TelemetryTransmitterTask, NULL, 32768, 150, 0), CFE_SUCCESS); UtAssert_INT32_EQ( CFE_ES_CreateChildTask(&BulkCmd.TaskIdRecv, "CmdRecv", UT_CommandReceiverTask, NULL, 32768, 100, 0), From 43ccbe8eee5d7a57189fffb09b2a9d894fab5431 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez Pedraza" Date: Thu, 29 Aug 2024 13:50:07 -0400 Subject: [PATCH 3/3] 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..bf7f6c159 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)*/ +static 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;