Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from FreeRTOS:main #76

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions event_groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,7 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
{
if( xAlreadyYielded == pdFALSE )
{
#if ( configNUMBER_OF_CORES == 1 )
{
portYIELD_WITHIN_API();
}
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
{
vTaskYieldWithinAPI();
}
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
taskYIELD_WITHIN_API();
}
else
{
Expand Down Expand Up @@ -417,15 +409,7 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
{
if( xAlreadyYielded == pdFALSE )
{
#if ( configNUMBER_OF_CORES == 1 )
{
portYIELD_WITHIN_API();
}
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
{
vTaskYieldWithinAPI();
}
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
taskYIELD_WITHIN_API();
}
else
{
Expand Down
8 changes: 0 additions & 8 deletions include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,6 @@

#endif /* portGET_ISR_LOCK */

#ifndef portCHECK_IF_IN_ISR

#if ( configNUMBER_OF_CORES > 1 )
#error portCHECK_IF_IN_ISR is required in SMP
#endif

#endif /* portCHECK_IF_IN_ISR */

#ifndef portENTER_CRITICAL_FROM_ISR

#if ( configNUMBER_OF_CORES > 1 )
Expand Down
6 changes: 6 additions & 0 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -3330,6 +3330,12 @@ BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;
* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
*----------------------------------------------------------*/

#if ( configNUMBER_OF_CORES == 1 )
#define taskYIELD_WITHIN_API() portYIELD_WITHIN_API()
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
#define taskYIELD_WITHIN_API() vTaskYieldWithinAPI()
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */

/*
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
* INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
Expand Down
40 changes: 4 additions & 36 deletions queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,15 +1129,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
* is also a higher priority task in the pending ready list. */
if( xTaskResumeAll() == pdFALSE )
{
#if ( configNUMBER_OF_CORES == 1 )
{
portYIELD_WITHIN_API();
}
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
{
vTaskYieldWithinAPI();
}
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
taskYIELD_WITHIN_API();
}
}
else
Expand Down Expand Up @@ -1616,15 +1608,7 @@ BaseType_t xQueueReceive( QueueHandle_t xQueue,

if( xTaskResumeAll() == pdFALSE )
{
#if ( configNUMBER_OF_CORES == 1 )
{
portYIELD_WITHIN_API();
}
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
{
vTaskYieldWithinAPI();
}
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
taskYIELD_WITHIN_API();
}
else
{
Expand Down Expand Up @@ -1817,15 +1801,7 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,

if( xTaskResumeAll() == pdFALSE )
{
#if ( configNUMBER_OF_CORES == 1 )
{
portYIELD_WITHIN_API();
}
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
{
vTaskYieldWithinAPI();
}
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
taskYIELD_WITHIN_API();
}
else
{
Expand Down Expand Up @@ -2013,15 +1989,7 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue,

if( xTaskResumeAll() == pdFALSE )
{
#if ( configNUMBER_OF_CORES == 1 )
{
portYIELD_WITHIN_API();
}
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
{
vTaskYieldWithinAPI();
}
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
taskYIELD_WITHIN_API();
}
else
{
Expand Down
92 changes: 29 additions & 63 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,31 @@

#define taskBITS_PER_BYTE ( ( size_t ) 8 )

#if ( configNUMBER_OF_CORES > 1 )

/* Yields the given core. This must be called from a critical section and xCoreID
* must be valid. This macro is not required in single core since there is only
* one core to yield. */
#define prvYieldCore( xCoreID ) \
do { \
if( xCoreID == ( BaseType_t ) portGET_CORE_ID() ) \
{ \
/* Pending a yield for this core since it is in the critical section. */ \
xYieldPendings[ xCoreID ] = pdTRUE; \
} \
else \
{ \
/* Request other core to yield if it is not requested before. */ \
if( pxCurrentTCBs[ xCoreID ]->xTaskRunState != taskTASK_SCHEDULED_TO_YIELD ) \
{ \
portYIELD_CORE( xCoreID ); \
pxCurrentTCBs[ xCoreID ]->xTaskRunState = taskTASK_SCHEDULED_TO_YIELD; \
} \
} \
} while( 0 )
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
/*-----------------------------------------------------------*/

/*
* Task control block. A task control block (TCB) is allocated for each task,
* and stores task state information, including a pointer to the task's context
Expand Down Expand Up @@ -527,14 +552,6 @@ static BaseType_t prvCreateIdleTasks( void );

#if ( configNUMBER_OF_CORES > 1 )

/*
* Yields the given core.
*/
static void prvYieldCore( BaseType_t xCoreID );
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */

#if ( configNUMBER_OF_CORES > 1 )

/*
* Yields a core, or cores if multiple priorities are not allowed to run
* simultaneously, to allow the task pxTCB to run.
Expand Down Expand Up @@ -811,33 +828,6 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;

/*-----------------------------------------------------------*/

#if ( configNUMBER_OF_CORES > 1 )
static void prvYieldCore( BaseType_t xCoreID )
{
/* This must be called from a critical section and xCoreID must be valid. */
if( ( portCHECK_IF_IN_ISR() == pdTRUE ) && ( xCoreID == ( BaseType_t ) portGET_CORE_ID() ) )
{
xYieldPendings[ xCoreID ] = pdTRUE;
}
else
{
if( pxCurrentTCBs[ xCoreID ]->xTaskRunState != taskTASK_SCHEDULED_TO_YIELD )
{
if( xCoreID == ( BaseType_t ) portGET_CORE_ID() )
{
xYieldPendings[ xCoreID ] = pdTRUE;
}
else
{
portYIELD_CORE( xCoreID );
pxCurrentTCBs[ xCoreID ]->xTaskRunState = taskTASK_SCHEDULED_TO_YIELD;
}
}
}
}
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
/*-----------------------------------------------------------*/

#if ( configNUMBER_OF_CORES > 1 )
static void prvYieldForTask( const TCB_t * pxTCB )
{
Expand Down Expand Up @@ -2195,11 +2185,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
* have put ourselves to sleep. */
if( xAlreadyYielded == pdFALSE )
{
#if ( configNUMBER_OF_CORES == 1 )
portYIELD_WITHIN_API();
#else
vTaskYieldWithinAPI();
#endif
taskYIELD_WITHIN_API();
}
else
{
Expand Down Expand Up @@ -2251,11 +2237,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
* have put ourselves to sleep. */
if( xAlreadyYielded == pdFALSE )
{
#if ( configNUMBER_OF_CORES == 1 )
portYIELD_WITHIN_API();
#else
vTaskYieldWithinAPI();
#endif
taskYIELD_WITHIN_API();
}
else
{
Expand Down Expand Up @@ -7253,15 +7235,7 @@ TickType_t uxTaskResetEventItemValue( void )
* section (some will yield immediately, others wait until the
* critical section exits) - but it is not something that
* application code should ever do. */
#if ( configNUMBER_OF_CORES == 1 )
{
portYIELD_WITHIN_API();
}
#else
{
vTaskYieldWithinAPI();
}
#endif
taskYIELD_WITHIN_API();
}
else
{
Expand Down Expand Up @@ -7344,15 +7318,7 @@ TickType_t uxTaskResetEventItemValue( void )
* section (some will yield immediately, others wait until the
* critical section exits) - but it is not something that
* application code should ever do. */
#if ( configNUMBER_OF_CORES == 1 )
{
portYIELD_WITHIN_API();
}
#else
{
vTaskYieldWithinAPI();
}
#endif
taskYIELD_WITHIN_API();
}
else
{
Expand Down
10 changes: 1 addition & 9 deletions timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,15 +771,7 @@
* block time to expire. If a command arrived between the
* critical section being exited and this yield then the yield
* will not cause the task to block. */
#if ( configNUMBER_OF_CORES == 1 )
{
portYIELD_WITHIN_API();
}
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
{
vTaskYieldWithinAPI();
}
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
taskYIELD_WITHIN_API();
}
else
{
Expand Down
Loading