FreeRTOS / FreeRTOS-Kernel

FreeRTOS kernel files only, submoduled into https://github.com/FreeRTOS/FreeRTOS and various other repos.
https://www.FreeRTOS.org
MIT License
2.76k stars 1.12k forks source link

Update taskYIELD_IF_USING_PREEMPTION macro #769

Closed chinglee-iot closed 1 year ago

chinglee-iot commented 1 year ago

Update taskYIELD_IF_USING_PREEMPTIONto align single core and SMP implementation.

Description

taskYIELD_IF_USING_PREEMPTIONis called in the following two scenarios in single core implementation:

In single core implementation both of the scenarios is achieved by calling portYIELD_WITHIN_API(). However, these scenarios are handled differently in SMP. prvYieldCore() is called when requesting a running task to yield and prvYieldForTask() is called when yielding a running task for higher priority task.

This PR tries to align these scenarios with the same macro in single core and SMP. A new macro taskYIELD_ANY_CORE_IF_USING_PREEMPTION is added. Existing taskYIELD_IF_USING_PREEMPTION macro is renamed to taskYIELD_TASK_CORE_IF_USING_PREEMPTION with one parameter.

Single core implementation

#define taskYIELD_TASK_CORE_IF_USING_PREEMPTION( pxTCB ) portYIELD_WITHIN_API()
#define taskYIELD_ANY_CORE_IF_USING_PREEMPTION( pxTCB )  \
if( pxCurrentTCB->uxPriority < ( pxTCB )->uxPriority ) \
{ \
    portYIELD_WITHIN_API(); \
}

SMP implementation

#define taskYIELD_TASK_CORE_IF_USING_PREEMPTION( pxTCB ) prvYieldCore( ( pxTCB )->xTaskRunState )
#define taskYIELD_ANY_CORE_IF_USING_PREEMPTION( pxTCB )  prvYieldForTask( pxTCB )

Checklist:

Related Issue

Address #750 comment in line 61.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% :warning:

Comparison is base (26c48de) 94.35% compared to head (498083c) 94.35%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #769 +/- ## ========================================== - Coverage 94.35% 94.35% -0.01% ========================================== Files 6 6 Lines 2446 2443 -3 Branches 598 598 ========================================== - Hits 2308 2305 -3 Misses 85 85 Partials 53 53 ``` | [Flag](https://app.codecov.io/gh/FreeRTOS/FreeRTOS-Kernel/pull/769/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=FreeRTOS) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/FreeRTOS/FreeRTOS-Kernel/pull/769/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=FreeRTOS) | `94.35% <100.00%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=FreeRTOS#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files Changed](https://app.codecov.io/gh/FreeRTOS/FreeRTOS-Kernel/pull/769?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=FreeRTOS) | Coverage Δ | | |---|---|---| | [tasks.c](https://app.codecov.io/gh/FreeRTOS/FreeRTOS-Kernel/pull/769?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=FreeRTOS#diff-dGFza3MuYw==) | `94.81% <100.00%> (-0.02%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

chinglee-iot commented 1 year ago

@RichardBarry This PR is updated. Would you like to review this PR again?