Skip to content

Commit

Permalink
Fix #2592, Only yield CPU once every 1024 messages
Browse files Browse the repository at this point in the history
  • Loading branch information
pepepr08 committed Aug 29, 2024
1 parent 97d7f31 commit d32079a
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions modules/cfe_testcase/src/sb_performance_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check notice

Code scanning / CodeQL

Global could be static Note test

The global variable UT_CpuYieldMask is not accessed outside of sb_performance_test.c and could be made static.

/* State structure for multicore test - shared between threads */
typedef struct UT_BulkMultiCoreSharedState
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d32079a

Please sign in to comment.