Skip to content

Commit f08c3c5

Browse files
committed
Use unsafe get in critical section directory
1 parent 2883653 commit f08c3c5

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

tasks.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@
188188
} \
189189
\
190190
/* listGET_OWNER_OF_NEXT_ENTRY indexes through the list, so the tasks of \
191-
* the same priority get an equal share of the processor time. */ \
192-
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) ); \
191+
* the same priority get an equal share of the processor time. */ \
192+
listGET_OWNER_OF_NEXT_ENTRY( prvGetCurrentTaskTCBUnsafe(), &( pxReadyTasksLists[ uxTopPriority ] ) ); \
193193
uxTopReadyPriority = uxTopPriority; \
194194
} while( 0 ) /* taskSELECT_HIGHEST_PRIORITY_TASK */
195195
#else /* if ( configNUMBER_OF_CORES == 1 ) */
@@ -224,7 +224,7 @@
224224
/* Find the highest priority list that contains ready tasks. */ \
225225
portGET_HIGHEST_PRIORITY( uxTopPriority, uxTopReadyPriority ); \
226226
configASSERT( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ uxTopPriority ] ) ) > 0 ); \
227-
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) ); \
227+
listGET_OWNER_OF_NEXT_ENTRY( prvGetCurrentTaskTCBUnsafe(), &( pxReadyTasksLists[ uxTopPriority ] ) ); \
228228
} while( 0 )
229229

230230
/*-----------------------------------------------------------*/
@@ -307,8 +307,8 @@
307307

308308
/* Returns pdTRUE if the task is actively running and not scheduled to yield. */
309309
#if ( configNUMBER_OF_CORES == 1 )
310-
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( pxTCB ) == pxCurrentTCB ) ? ( pdTRUE ) : ( pdFALSE ) )
311-
#define taskTASK_IS_RUNNING_OR_SCHEDULED_TO_YIELD( pxTCB ) ( ( ( pxTCB ) == pxCurrentTCB ) ? ( pdTRUE ) : ( pdFALSE ) )
310+
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( pxTCB ) == prvGetCurrentTaskTCBUnsafe() ) ? ( pdTRUE ) : ( pdFALSE ) )
311+
#define taskTASK_IS_RUNNING_OR_SCHEDULED_TO_YIELD( pxTCB ) ( ( ( pxTCB ) == prvGetCurrentTaskTCBUnsafe() ) ? ( pdTRUE ) : ( pdFALSE ) )
312312
#else
313313
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( ( pxTCB )->xTaskRunState >= ( BaseType_t ) 0 ) && ( ( pxTCB )->xTaskRunState < ( BaseType_t ) configNUMBER_OF_CORES ) ) ? ( pdTRUE ) : ( pdFALSE ) )
314314
#define taskTASK_IS_RUNNING_OR_SCHEDULED_TO_YIELD( pxTCB ) ( ( ( pxTCB )->xTaskRunState != taskTASK_NOT_RUNNING ) ? ( pdTRUE ) : ( pdFALSE ) )
@@ -2066,11 +2066,12 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
20662066
{
20672067
uxCurrentNumberOfTasks = ( UBaseType_t ) ( uxCurrentNumberOfTasks + 1U );
20682068

2069-
if( pxCurrentTCB == NULL )
2069+
/* Invoking a functon in a condition here for performance consideration. */
2070+
if( prvGetCurrentTaskTCBUnsafe() == NULL )
20702071
{
20712072
/* There are no other tasks, or all the other tasks are in
20722073
* the suspended state - make this the current task. */
2073-
pxCurrentTCB = pxNewTCB;
2074+
prvSetCurrentTCB( pxNewTCB );
20742075

20752076
if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 )
20762077
{
@@ -3301,7 +3302,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
33013302
* NULL so when the next task is created pxCurrentTCB will
33023303
* be set to point to it no matter what its relative priority
33033304
* is. */
3304-
pxCurrentTCB = NULL;
3305+
prvSetCurrentTCB( NULL );
33053306
}
33063307
else
33073308
{
@@ -4129,7 +4130,7 @@ BaseType_t xTaskResumeAll( void )
41294130

41304131
#if ( configNUMBER_OF_CORES == 1 )
41314132
{
4132-
taskYIELD_TASK_CORE_IF_USING_PREEMPTION( pxCurrentTCB );
4133+
taskYIELD_TASK_CORE_IF_USING_PREEMPTION( prvGetCurrentTaskTCBUnsafe() );
41334134
}
41344135
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
41354136
}
@@ -8704,7 +8705,7 @@ void vTaskResetState( void )
87048705
/* Task control block. */
87058706
#if ( configNUMBER_OF_CORES == 1 )
87068707
{
8707-
pxCurrentTCB = NULL;
8708+
prvSetCurrentTCB( NULL );
87088709
}
87098710
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
87108711

0 commit comments

Comments
 (0)