Skip to content

Commit

Permalink
tasks.c - vTaskStartScheduler() should clean up state to enable vTask…
Browse files Browse the repository at this point in the history
…StartScheduler() to be called again

In the posix use case it is possible to repeatedly start and stop the scheduler.

FreeRTOS has no routine for initializing internal state as internal state variables are
initialized at application start up.

For subsequent scheduler starts there were variables left with state that was preventing
the scheduler from starting up.

Re-initialize these before vTaskStartScheduler() exits.
  • Loading branch information
cmorganBE committed Dec 5, 2023
1 parent 9d7bad7 commit f38dd73
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3734,6 +3734,21 @@ void vTaskStartScheduler( void )
* from getting optimized out as it is no longer used by the kernel. */
( void ) uxTopUsedPriority;

/* clean up so vTaskStartScheduler can be called again */
#if ( configNUMBER_OF_CORES == 1 )
pxCurrentTCB = NULL;
#else
{
BaseType_t coreIndex;
for( coreIndex = 0; coreIndex < configNUMBER_OF_CORES; coreIndex++ )
{
pxCurrentTCBs[ coreIndex ] = NULL;
}
}
#endif

uxCurrentNumberOfTasks = 0;

traceRETURN_vTaskStartScheduler();
}
/*-----------------------------------------------------------*/
Expand Down

0 comments on commit f38dd73

Please sign in to comment.