Skip to content

Commit

Permalink
Add core affinity bits check
Browse files Browse the repository at this point in the history
  • Loading branch information
chinglee-iot committed Sep 4, 2023
1 parent 80a390c commit 39bdd2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,10 @@
#error configUSE_TASK_PREEMPTION_DISABLE is not supported in single core FreeRTOS
#endif

#if ( ( configNUMBER_OF_CORES == 1 ) && ( configUSE_CORE_AFFINITY != 0 ) )
#error configUSE_CORE_AFFINITY is not supported in single core FreeRTOS
#endif

#ifndef configINITIAL_TICK_COUNT
#define configINITIAL_TICK_COUNT 0
#endif
Expand Down
9 changes: 8 additions & 1 deletion tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to
#endif

#if ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 )
UBaseType_t uxCoreAffinityMask; /*< Used to link the task to certain cores. UBaseType_t must have greater than or equal to the number of bits as confNUM_CORES. */
UBaseType_t uxCoreAffinityMask; /**< Used to link the task to certain cores. UBaseType_t must have greater than or equal to the number of bits as configNUMBER_OF_CORES. */
#endif

ListItem_t xStateListItem; /**< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */
Expand Down Expand Up @@ -3257,6 +3257,13 @@ void vTaskStartScheduler( void )
{
BaseType_t xReturn;

#if ( configUSE_CORE_AFFINITY == 1 )
{
/* UBaseType_t must have greater than or equal to the number of bits as confNUMBER_OF_CORES. */
configASSERT( configNUMBER_OF_CORES <= ( sizeof( UBaseType_t ) * 8 ) );
}
#endif

xReturn = prvCreateIdleTasks();

#if ( configUSE_TIMERS == 1 )
Expand Down

0 comments on commit 39bdd2a

Please sign in to comment.