Skip to content

Commit

Permalink
update tasks.c
Browse files Browse the repository at this point in the history
  • Loading branch information
feilipu committed Jan 23, 2024
1 parent f44c098 commit 0e0df01
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=FreeRTOS
version=11.0.1-3
version=11.0.1-4
author=Richard Barry <[email protected]>
maintainer=Phillip Stevens <[email protected]>
sentence=FreeRTOS Real Time Operating System implemented for AVR (Uno, Nano, Leonardo, Mega).
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ My other [AVRfreeRTOS Sourceforge Repository](https://sourceforge.net/projects/a

This library was the genesis of [generalised support for the ATmega platform within FreeRTOS](https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/48).

Over the past few years freeRTOS development has become increasingly 32-bit orientated, now including symmetric multiprocessing, with little change or improvement for the 8-bit world. As such I'm treating this FreeRTOS V11.0.1 (updated January 20 2024) as my LTS release.
Over the past few years freeRTOS development has become increasingly 32-bit orientated, now including symmetric multiprocessing, with little change or improvement for the 8-bit world. As such I'm treating this FreeRTOS V11.0.1 (updated January 23 2024) as my LTS release.

## General

Expand Down
73 changes: 36 additions & 37 deletions src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
void vTaskDelete( TaskHandle_t xTaskToDelete )
{
TCB_t * pxTCB;
BaseType_t xDeleteTCBInIdleTask = pdFALSE;

traceENTER_vTaskDelete( xTaskToDelete );

Expand Down Expand Up @@ -2243,6 +2244,9 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
* portPRE_TASK_DELETE_HOOK() does not return in the Win32 port. */
traceTASK_DELETE( pxTCB );

/* Delete the task TCB in idle task. */
xDeleteTCBInIdleTask = pdTRUE;

/* The pre-delete hook is primarily for the Windows simulator,
* in which Windows specific clean up operations are performed,
* after which it is not possible to yield away from this task -
Expand All @@ -2264,61 +2268,56 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
prvResetNextTaskUnblockTime();
}
}
taskEXIT_CRITICAL();

#if ( configNUMBER_OF_CORES == 1 )
/* If the task is not deleting itself, call prvDeleteTCB from outside of
* critical section. If a task deletes itself, prvDeleteTCB is called
* from prvCheckTasksWaitingTermination which is called from Idle task. */
if( xDeleteTCBInIdleTask != pdTRUE )
{
taskEXIT_CRITICAL();

/* If the task is not deleting itself, call prvDeleteTCB from outside of
* critical section. If a task deletes itself, prvDeleteTCB is called
* from prvCheckTasksWaitingTermination which is called from Idle task. */
if( pxTCB != pxCurrentTCB )
{
prvDeleteTCB( pxTCB );
}
prvDeleteTCB( pxTCB );
}

/* Force a reschedule if it is the currently running task that has just
* been deleted. */
if( xSchedulerRunning != pdFALSE )
/* Force a reschedule if it is the currently running task that has just
* been deleted. */
if( xSchedulerRunning != pdFALSE )
{
#if ( configNUMBER_OF_CORES == 1 )
{
if( pxTCB == pxCurrentTCB )
{
configASSERT( uxSchedulerSuspended == 0 );
portYIELD_WITHIN_API();
taskYIELD_WITHIN_API();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
}
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
{
/* If a running task is not deleting itself, call prvDeleteTCB. If a running
* task deletes itself, prvDeleteTCB is called from prvCheckTasksWaitingTermination
* which is called from Idle task. */
if( pxTCB->xTaskRunState == taskTASK_NOT_RUNNING )
{
prvDeleteTCB( pxTCB );
}

/* Force a reschedule if the task that has just been deleted was running. */
if( ( xSchedulerRunning != pdFALSE ) && ( taskTASK_IS_RUNNING( pxTCB ) == pdTRUE ) )
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
{
if( pxTCB->xTaskRunState == ( BaseType_t ) portGET_CORE_ID() )
{
configASSERT( uxSchedulerSuspended == 0 );
vTaskYieldWithinAPI();
}
else
/* It is important to use critical section here because
* checking run state of a task must be done inside a
* critical section. */
taskENTER_CRITICAL();
{
prvYieldCore( pxTCB->xTaskRunState );
if( taskTASK_IS_RUNNING( pxTCB ) == pdTRUE )
{
if( pxTCB->xTaskRunState == ( BaseType_t ) portGET_CORE_ID() )
{
configASSERT( uxSchedulerSuspended == 0 );
taskYIELD_WITHIN_API();
}
else
{
prvYieldCore( pxTCB->xTaskRunState );
}
}
}
taskEXIT_CRITICAL();
}

taskEXIT_CRITICAL();
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
}
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */

traceRETURN_vTaskDelete();
}
Expand Down

0 comments on commit 0e0df01

Please sign in to comment.