-
Notifications
You must be signed in to change notification settings - Fork 143
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
Implement Protothreads as Fibers #1001
Implement Protothreads as Fibers #1001
Conversation
6ca9dfb
to
73586d1
Compare
Thanks for starting to work on this. I have the feeling that the resumable function compatibility layer could be much simpler than the proposed solution. The resumable function mechanism itself shouldn't be required anymore using fibers. Can't we define all the resumable classes as empty no-ops and just use
A long time ago I have played around with this. That was my first prototype of that simple concept which completely ignored protothreads, but it let's you use resumable drivers from fibers: chris-durand@5f3c900 |
934f34b
to
11c06d9
Compare
Yeah, good point. I wanted to have something completely drop-in replacable, but it makes no sense to only go half-way. |
260778d
to
40d4bde
Compare
I made the resumables transparent now, which is nice, because you can now simply call "ex-resumabe" functions without any macros at all. This even works without a scheduler at all ( |
bd11fc2
to
7b813b5
Compare
fb58e6a
to
7ff65db
Compare
Ok, I've refactored a lot of the implementation to make fiber consume a little bit less stack and be restartable.
|
7ff65db
to
42b5add
Compare
42b5add
to
ca214fe
Compare
ca214fe
to
0ebf256
Compare
0ebf256
to
a762500
Compare
Ok, this is now quite polished. I refactored the context API and implementation so that stack watermarking can be used to measure stack usage on all platforms. Fixed some minor things on AVR. I'm very happy with this now. If you want to review and it's a bit much, then focus more on the usability of the fiber API, rather than the implementation. It's easier to get the implementation right, since it simply crashes if its wrong ;-P |
d047f6e
to
63fc9b6
Compare
b9f93ec
to
965efe7
Compare
Man, this crap macOS CI is a pain to maintain without containers. |
965efe7
to
f2692ca
Compare
I added a bunch more doxygen documentation and moved the stack usage into the fiber context. |
9d02a37
to
17772ef
Compare
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.
Very nice!
17772ef
to
f8d650d
Compare
- Fiber compound class with integrated stack. - Fibers can be restarted. - Fiber stack usage measurement. - Correct stack word type on AVRs. - Simpler context API.
f8d650d
to
8b07dba
Compare
Adds an lbuild option to replace the Protothread and (Nested)Resumable implementation with a fiber one that is almost entirely backwards compatible.
8b07dba
to
c1bf519
Compare
Alright, thanks! My next plans are to implement light-weight mutex, semaphore, signals, and queues, so that we can have a smarter/simpler scheduler than the linked list right now. My ultimate goal is to have a composable fiber implementation that still works with FreeRTOS above and C++ coroutines below:
|
Huge shout-out to everyone who helped implement the Fibers 🥇 I just started using them for the first time in a larger project and about 1h in, it feels so much nicer then the @%$!!@# PROTOTHREADS already 😸 Although, default stack size could be 1k (at leasts thats what I need for even mild use of Also, my systems default arm gcc 13 can be used again, no more #1012 ❤️ Maybe, this comment should have gone to #743 too |
Adds a
modm:processing:protothread:use_fiber
option that makes themodm::Protothread
behave like a fiber with a default stack.The only change required is to replace the main loop calling all the protothread
run()
functions with themodm::fiber::Scheduler::run();
function.modm:__fibers
guard option and make themodm:processing:fiber
module available by default.RF_*
andPT_*
macros..noinit
sections, since they are constructed only at runtime.