multi-thread in the Patmos Platform#582
Open
EhsanKhodadad wants to merge 7 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to add multi-threaded runtime support for the Patmos platform by introducing Patmos implementations of the LF threading/synchronization abstractions when LF_SINGLE_THREADED is not defined.
Changes:
- Added a Patmos “threaded” branch in
lf_patmos_support.cwith implementations for threads, mutexes, and condition variables. - Added Patmos platform typedefs for
lf_thread_t,lf_mutex_t, andlf_cond_tunder!LF_SINGLE_THREADED.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| low_level_platform/impl/src/lf_patmos_support.c | Adds Patmos-side threaded implementations (threads/mutex/cond) and related helpers under #else of LF_SINGLE_THREADED. |
| low_level_platform/api/platform/lf_patmos_support.h | Introduces threaded Patmos typedefs and includes <pthread.h> when !LF_SINGLE_THREADED. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <copilot@github.com>
edwardalee
requested changes
May 12, 2026
edwardalee
left a comment
Contributor
There was a problem hiding this comment.
Looks to me like the Copilot suggestions need to be addressed.
Contributor
|
As you address issues raised by Copilot, please record a brief comment on how the issue was addressed and mark the comment "Resolved". |
…e LF_SINGLE_THREADED branch in lf_patmos_support_c
Comment on lines
+167
to
+173
| int lf_disable_interrupts_nested() { | ||
| // Disable interrupts first and increment the per-core nesting counter. | ||
| intr_disable(); | ||
| volatile int* nested_counter = _lf_current_core_nested_counter(); | ||
| (*nested_counter)++; | ||
| return 0; | ||
| } |
Comment on lines
21
to
33
| int lf_atomic_fetch_add(int* ptr, int value) { | ||
| lf_disable_interrupts_nested(); | ||
| #if defined(PLATFORM_PATMOS) && !defined(LF_SINGLE_THREADED) | ||
| _lf_patmos_global_lock_acquire(); | ||
| #endif | ||
| int res = *ptr; | ||
| *ptr += value; | ||
| #if defined(PLATFORM_PATMOS) && !defined(LF_SINGLE_THREADED) | ||
| _lf_patmos_global_lock_release(); | ||
| #endif | ||
| lf_enable_interrupts_nested(); | ||
| return res; | ||
| } |
Comment on lines
+25
to
+38
| #if !defined(LF_SINGLE_THREADED) | ||
| #include <pthread.h> | ||
| typedef pthread_t lf_thread_t; | ||
| typedef pthread_mutex_t lf_mutex_t; | ||
| typedef struct { | ||
| lf_mutex_t* mutex; | ||
| pthread_cond_t condition; | ||
| } lf_cond_t; | ||
| #if !defined(LF_SINGLE_THREADED) | ||
| // Cross-core global lock used by atomic implementations on Patmos. | ||
| void _lf_patmos_global_lock_acquire(void); | ||
| void _lf_patmos_global_lock_release(void); | ||
| #endif | ||
| #endif |
Comment on lines
99
to
107
| int lf_disable_interrupts_nested() { | ||
| // For the single-threaded path, disable interrupts first then increment | ||
| // the nesting counter to avoid preemption windows on this core. | ||
| intr_disable(); | ||
| if (_lf_num_nested_critical_sections++ == 0) { | ||
| intr_disable(); | ||
| // already disabled above | ||
| } | ||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.