Skip to content

POSIX Threads for Arduino #5914

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

Closed
mikaelpatel opened this issue Jan 26, 2017 · 5 comments
Closed

POSIX Threads for Arduino #5914

mikaelpatel opened this issue Jan 26, 2017 · 5 comments

Comments

@mikaelpatel
Copy link

There has been some questions about AVR implementation of the Scheduler. I have made available a portable Scheduler implementation which work on AVR, SAM, SAMD, Teensy, etc. https://github.com/mikaelpatel/Arduino-Scheduler.

There has also been a discussion about extending the Scheduler functionality. This has brought me to the conclusion that a possible way forward is to implement a sub-set of the POSIX Thread API for Arduino (pthreads). See mikaelpatel/Arduino-Scheduler#13.

If there is an interest I could make time to do some work on this.

@shiftleftplusone
Copy link

IMO that will be really incredibly awesome!
(y)

@shiftleftplusone
Copy link

shiftleftplusone commented Feb 11, 2017

I am really curious why not everybody round here is cheering for joy in anticipation of getting a reliable, worldwide tested and approved pre-emptive multithreading lib already running successfully on either C/C++ platform!
Can no one else really imagine the tremendous and insane possibilities which would be introduced to the Arduino world by such a POSIX pthread API lib implementation?

@PaulStoffregen
Copy link
Contributor

PaulStoffregen commented Feb 15, 2017

I am really curious why not everybody round here is cheering for joy in anticipation of getting a reliable, worldwide tested and approved pre-emptive multithreading lib...

Just because you may have a "worldwide tested and approved pre-emptive multithreading lib" doesn't mean the huge ecosystem of other libraries will work in a multithreaded environment. In fact, the vast majority use static data or other techniques that will randomly & intermittently fail if accessed from multiple preemptively scheduled threads.

Even if all those problems are solved, multi-threaded programming is difficult work. Race conditions, deadlocks and other pitfalls await anyone trying to build their own inter-thread communication or synchronization code, even if using a well known API like pthreads.

Preemptive threading is a powerful tool. Amazing things can be done with threads in the hands of the right people. But it's not a cure-all. Especially for novices, preemptive scheduling is a very sharp double-edged sword which should be wielded with caution.

@mikaelpatel
Copy link
Author

@PaulStoffregen Thanks for your comment. I forgot to motivate why I closed this issue/proposal. Your comment is very much to the point. I can only agree.

The Scheduler (pthreads) risks opening a can-of-worms too large to handle. The current Arduino core(s) needs refactoring before this becomes feasible.

@shiftleftplusone
Copy link

shiftleftplusone commented Feb 15, 2017

I agree. If once being established, it has to run reliably.
Unfortunately for Arduino there is missing any reliably working multithreading lib ftm, some work not at all for AVRs, some have severe issues for the Due. And for neither one threads may be stopped not to run infinitely and later be restarted in case of need.
That's very poor.
Perhaps this is really due to the fact that " the current Arduino core(s) needs refactoring".
Anyway,with Posix pthread I am already doing "amazing things" on my Raspi, probably because of the fact that for me it's " in the hands of the right people".

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

No branches or pull requests

3 participants