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

pthread allow Stack on Spiram (IDFGH-7045) #8662

Closed
f-hoepfinger-hr-agrartechnik opened this issue Mar 25, 2022 · 6 comments
Closed

pthread allow Stack on Spiram (IDFGH-7045) #8662

f-hoepfinger-hr-agrartechnik opened this issue Mar 25, 2022 · 6 comments
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Feature Request Feature request for IDF

Comments

@f-hoepfinger-hr-agrartechnik
Copy link
Contributor

when you have a lot of Tasks,
internal Memory might be used up fast.

now,
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/kconfig.html#config-spiram-allow-stack-external-memory
allow use of Stack on SPIRAM.
but not via C++ Pthreads.
https://github.com/espressif/esp-idf/tree/master/examples/cxx/pthread

would be a nice Extension right ?

Thanks,
Franz

@f-hoepfinger-hr-agrartechnik f-hoepfinger-hr-agrartechnik added the Type: Feature Request Feature request for IDF label Mar 25, 2022
@espressif-bot espressif-bot added the Status: Opened Issue is new label Mar 25, 2022
@github-actions github-actions bot changed the title pthread allow Stack on Spiram pthread allow Stack on Spiram (IDFGH-7045) Mar 25, 2022
@0xjakob
Copy link
Collaborator

0xjakob commented Mar 28, 2022

@f-hoepfinger-hr-agrartechnik

would be a nice Extension right ?

Certainly! But I'm afraid that the constructor of std::thread does not allow any additional parameters than the actual function to be executed in the thread.

Maybe I missed something, so if you have another idea, please let me know!

@0xjakob 0xjakob self-assigned this Mar 28, 2022
@franz-ms-muc
Copy link
Contributor

esp_pthread_set_cfg(&cfg)
The cfg could be extended.

@0xjakob
Copy link
Collaborator

0xjakob commented Mar 30, 2022

@f-hoepfinger-hr-agrartechnik @franz-ms-muc I see now (Should have looked at the example more thoroughly). Just to clarify: you would like a possibility to configure std::thread via the esp_pthread API? If that's correct, then I think it's possible. We would add this to our backlog but we currently have some other high-priority tasks. So it might take some (> 1 month). If you eventually implement something like this yourself, feel free to open a pull request and then we can discuss there.

@f-hoepfinger-hr-agrartechnik
Copy link
Contributor Author

Hi,

we did one implementation here:
https://github.com/hr-agrartechnik/esp-idf/blob/HR_4.4_ram/components/pthread/pthread.c

but i would not want to open a Pull Request as i feel the Quality is not good enough for a Pull request.
maybe later when we have done a bunch more test.

it is "generally" running OK, so we use it in a Prototype.

@f-hoepfinger-hr-agrartechnik
Copy link
Contributor Author

Ported same to 4.4.2
https://github.com/hr-agrartechnik/esp-idf/tree/HR_4.4.2_ram

any outlook that we can get such in ESP-IDF ?

@f-hoepfinger-hr-agrartechnik
Copy link
Contributor Author

will be here shortly.
#10623

f-hoepfinger-hr-agrartechnik added a commit to hr-agrartechnik/esp-idf that referenced this issue Feb 4, 2023
externalmemory option.
Update components/pthread/include/esp_pthread.h

Co-authored-by: Ivan Grokhotkov <igrokhotkov@gmail.com>
Update components/pthread/pthread.c

Co-authored-by: Ivan Grokhotkov <igrokhotkov@gmail.com>
MALLOC_CAP_DEFAULT as default

"External ram" is probably not a very future-proof flag, since some chips might have more types of memory: TCM, internal slower memory, external faster memory, external slower memory, retention-capable memory. Using MALLOC_CAPS macros provides the same amount of flexibility as available in the heap allocation APIs.
Need to add free(stack_for_task); here


free(stack_for_task); free(taskTC); here as well


You also need to modify the pthread deletion code to free the memory, otherwise it would be leaked.


 this should be done together with deleting pthread structure
@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed and removed Status: Opened Issue is new labels Nov 15, 2023
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Reviewing Issue is being reviewed labels Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

4 participants