Skip to content

Add portTASK_SWITCH_HOOK #867

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

Merged
merged 9 commits into from
Dec 11, 2023

Conversation

Dazza0
Copy link
Contributor

@Dazza0 Dazza0 commented Oct 29, 2023

Description

This PR adds a portTASK_SWITCH_HOOK() in vTaskSwitchContext() to allow ports to inject behavior immediately after a context switch. For example, on the ESP32, this hook could be used for setting end of stack watchpoint (without needing to do it in the assembly routine that calls vTaskSwitchContext().

Test Steps

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

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

This commit adds a portTASK_SWITCH_HOOK() macro which allows ports to inject
behavior immediately after a context switch. For example, this macro could be
used by ports that need to set an end of stack watchpoint after a context
swtich.
@Dazza0 Dazza0 requested a review from a team as a code owner October 29, 2023 19:41
@RichardBarry
Copy link
Contributor

How does this differ to the existing traceTASK_SWITCHED_IN() and traceTASK_SWITCHED_OUT() macros?

@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (553caa1) 93.78% compared to head (f20bb91) 93.64%.
Report is 1 commits behind head on main.

❗ Current head f20bb91 differs from pull request most recent head d27a3b5. Consider uploading reports for the commit d27a3b5 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #867      +/-   ##
==========================================
- Coverage   93.78%   93.64%   -0.14%     
==========================================
  Files           6        6              
  Lines        3184     2550     -634     
  Branches      885      608     -277     
==========================================
- Hits         2986     2388     -598     
- Misses         91      107      +16     
+ Partials      107       55      -52     
Flag Coverage Δ
unittests 93.64% <100.00%> (-0.14%) ⬇️

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

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

@Dazza0
Copy link
Contributor Author

Dazza0 commented Oct 31, 2023

How does this differ to the existing traceTASK_SWITCHED_IN() and traceTASK_SWITCHED_OUT() macros?

Hi @RichardBarry, using the trace macros would also work. However, one consideration for not using trace macros to inject behavior is that the trace macros are sometimes provided by a third party debugging tool. For example, in ESP-IDF, we simply include the FreeRTOS trace macro headers provided by Segger Sysview.

aggarg added a commit to aggarg/FreeRTOS that referenced this pull request Dec 9, 2023
@amazonKamath amazonKamath self-requested a review December 10, 2023 04:59
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@chinglee-iot chinglee-iot merged commit bd0f87c into FreeRTOS:main Dec 11, 2023
@Dazza0 Dazza0 deleted the feature/add_portTASK_SWITCH_HOOK branch February 1, 2024 19:47
laroche pushed a commit to laroche/FreeRTOS-Kernel that referenced this pull request Apr 18, 2024
* Add a unit test for tasks.c

This test simulates the scenario when a task with priority higher than
the currently executing task is unblocked as a result of the
xTaskIncrementTick call.

This is needed to fix the coverage drop in PR FreeRTOS#568.

Signed-off-by: Gaurav Aggarwal <[email protected]>

* Add description for the test

Signed-off-by: Gaurav Aggarwal <[email protected]>

* Add doc for another test

Signed-off-by: Gaurav Aggarwal <[email protected]>

Signed-off-by: Gaurav Aggarwal <[email protected]>
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.

8 participants