Alright. I checked my implementation and yes. I did indeed use API functions within it.
if( xLoggingEnter() != pdFALSE)
{
va_list xArgs;
/* Watch out with small stacks. */
char pcBuffer[ 128 ];
BaseType_t xLength;
va_start( xArgs, pcFormat );
xLength = vsnprintf( pcBuffer, sizeof pcBuffer, pcFormat, xArgs );
printf( pcBuffer, xLength );
va_end( xArgs );
vLoggingExit();
}
and
static BaseType_t xLoggingEnter( void )
{
BaseType_t xResult;
if( xTaskGetSchedulerState() != taskSCHEDULER_RUNNING ) // <-- was == taskSCHEDULER_STARTED before
{
xResult = pdFALSE;
}
else
{
if( xLoggingSemaphore == NULL )
{
/* Create a mutex. */
xLoggingSemaphore = xSemaphoreCreateMutex();
}
if( xLoggingSemaphore != NULL )
{
/* Never wait longer than e.g. 2 ms. */
TickType_t xTicksToWait = pdMS_TO_TICKS( 0 );
xResult = xSemaphoreTake( xLoggingSemaphore, xTicksToWait );
}
else
{
xResult = pdFALSE;
}
}
return xResult;
}
And while I understand the problem with calling api functions while the scheduler is suspended, I do need to use them in order to make my printf thread safe. Therefore the FreeRTOS_printf
call in prvAcceptWaitClient
should be removed regardless since it is either never called (as in my new version of printf) or not thread safe which might not be a problem here but can’t be good practice in a OS.