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.
multi-thread in the Patmos Platform #582
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
base: main
Are you sure you want to change the base?
multi-thread in the Patmos Platform #582
Changes from all commits
3467fa5d2daa38File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the threaded (
#else) branch,_lf_num_nested_critical_sectionsis a single global counter shared by all threads/cores. With multiple threads, this can preventintr_disable()from being called on a core that enters its first critical section while another core is already in one (counter != 0), leaving interrupts enabled on that core. Make the nesting counter per-core/per-thread (similar to FlexPRET’scritical_section_num_nested[hartid]) or otherwise ensure interrupt masking is correctly applied independently on each core.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lf_thread_tis defined aspthread_tinlf_patmos_support.h, but herelf_thread_self()treats it as a struct with acpuidfield (lf_thread_t self = {0}; self.cpuid = ...). This will not compile and also conflicts with howlf_thread_create/joincast topthread_t. Makelf_thread_tconsistent across header and implementation (e.g., usepthread_teverywhere and returnpthread_self(), or define a Patmos-specific struct type in the header and adjust create/join accordingly).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested change was not compatible with Patmos implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lf_thread_id()/initialize_lf_thread_id()are also provided bylow_level_platform/impl/src/lf_platform_util.cfor all non-Zephyr, non-single-threaded builds. Adding Patmos-specific definitions here will cause duplicate symbol/linker errors in threaded Patmos builds. Either remove these definitions and rely on the shared implementation, or change the build/guards so only one implementation is compiled.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lf_cond_init()accepts an associated mutex but does not store or use it, which makes it impossible to implementlf_cond_wait()correctly. The core API assumes the condition variable knows its associated mutex (seelow_level_platform.hdocs and the POSIX implementation). Updatelf_cond_tto include a mutex pointer (or otherwise bind the mutex here) and use it inlf_cond_wait/_lf_cond_timedwait.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_lf_cond_timedwait()always returnsLF_TIMEOUTwithout waiting whennow < wakeup_time. Callers (e.g., watchdog and clock waits) expect this to block until either signaled or the timeout expires; returning immediately will cause busy looping and incorrect timing behavior. Implement a real timed wait (e.g., viapthread_cond_timedwait()with an absolute timespec) or an equivalent Patmos-specific mechanism.Uh oh!
There was an error while loading. Please reload this page.