Add vPortGenerateSimulatedInterruptFromWindowsThread in MSVC port #1044
+38
−24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Test Steps
N/A
Checklist:
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.