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

Update taskYIELD_IF_USING_PREEMPTION macro #769

Merged

Conversation

chinglee-iot
Copy link
Member

@chinglee-iot chinglee-iot commented Aug 31, 2023

Update taskYIELD_IF_USING_PREEMPTION to align single core and SMP implementation.

Description

taskYIELD_IF_USING_PREEMPTION is called in the following two scenarios in single core implementation:

  • Request the current running task to yield.
  • Request any running task to yield for the task.

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:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

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.

* taskYIELD_IF_USING_PREEMPTION is removed
@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% ⚠️

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

Additional details and impacted files
@@            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 Coverage Δ
unittests 94.35% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
tasks.c 94.81% <100.00%> (-0.02%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chinglee-iot chinglee-iot marked this pull request as ready for review August 31, 2023 13:36
@chinglee-iot chinglee-iot requested a review from a team as a code owner August 31, 2023 13:36
tasks.c Outdated Show resolved Hide resolved
Copy link
Contributor

@RichardBarry RichardBarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comment.

@chinglee-iot chinglee-iot changed the title Add taskYIELD_FOR_TASK_IF_USING_PREEMPTION macro Update taskYIELD_IF_USING_PREEMPTION macro Sep 6, 2023
@chinglee-iot
Copy link
Member Author

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

@chinglee-iot chinglee-iot dismissed RichardBarry’s stale review September 18, 2023 02:48

The PR is updated as suggested.

@chinglee-iot chinglee-iot merged commit 7db0e87 into FreeRTOS:main Sep 18, 2023
15 checks passed
@chinglee-iot chinglee-iot deleted the update-smp-taskYIELD_IF_USING_PREEMPTION branch October 20, 2023 10:52
@chinglee-iot chinglee-iot restored the update-smp-taskYIELD_IF_USING_PREEMPTION branch October 20, 2023 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants