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

Add vPortGenerateSimulatedInterruptFromWindowsThread in MSVC port #1044

Merged
merged 5 commits into from May 8, 2024

Conversation

chinglee-iot
Copy link
Member

@chinglee-iot chinglee-iot commented Apr 26, 2024

Add vPortGenerateSimulatedInterruptFromWindowsThread in MSVC port

Description

In the MSVC port of FreeRTOS, native Windows threads execute concurrently with FreeRTOS tasks and simulated interrupt handlers. Calling a FreeRTOS API from within a native Windows thread can lead to race conditions due to the concurrent execution. One way to enable synchronization between native Windows threads and FreeRTOS tasks is to make use of simulated interrupts. When a native Windows thread needs to invoke a FreeRTOS API, it generates a simulated interrupt and calls the FromISR API within the interrupt service routine (ISR).

The existing vPortGenerateSimulatedInterrupt function is designed to be called from within a FreeRTOS task, and it references the current thread structure. To facilitate calling FreeRTOS APIs from native Windows threads, this pull request introduces a new API function, vPortGenerateSimulatedInterruptFromWindowsThread. This function allows native Windows threads to generate simulated interrupts and subsequently call FreeRTOS APIs through the FromISR API, ensuring proper synchronization with FreeRTOS tasks.

Existing tick timer is an example of generating simulated interrupt from native windows thread.
Another example is the cellular comm interface in this commit. Comm interface can generate simulated interrupt to notify FreeRTOS task when UART RX data is received.

In this PR

  • Add vPortGenerateSimulatedInterruptFromWindowsThread to enable native windows thread to synchronize with FreeRTOS task through simulated interrupt.

Test Steps

N/A

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.

@chinglee-iot chinglee-iot requested a review from a team as a code owner April 26, 2024 10:14
* vPortGenerateSimulatedInterruptFromNative enables native windows
  thread to notify FreeRTOS task when certain task is done.
portable/MSVC-MingW/port.c Outdated Show resolved Hide resolved
portable/MSVC-MingW/portmacro.h Show resolved Hide resolved
Copy link

sonarcloud bot commented May 8, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@aggarg aggarg changed the title Add vPortGenerateSimulatedInterruptFromNative in MSVC port Add vPortGenerateSimulatedInterruptFromWindowsThread in MSVC port May 8, 2024
@aggarg aggarg merged commit 067d04e into FreeRTOS:main May 8, 2024
16 checks passed
@aggarg aggarg deleted the add-native-interrupt-MSVC branch May 8, 2024 06:33
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.

None yet

4 participants