taisei-project / koishi

Decently portable C11 coroutine library
https://taisei-project.github.io/koishi/
MIT License
23 stars 5 forks source link

ESP32 support #4

Open Klayflash opened 2 years ago

Klayflash commented 2 years ago

Hello!

Is context switching support planed for ESP32? For example ESP32 DEVKITV1 (ESP-WROOM-32).

I've found following:

Akaricchi commented 2 years ago

Hi, sorry for the delayed response.

No plans to support this, since I have neither a use-case nor the hardware for it, but I'll happily merge a pull request if someone is willing to implement it.

I have no experience with RTOS, but from reading a bit of those documents, their coroutine API doesn't look suitable for a Koishi backend implementation. Those coroutines are stackless, whereas Koishi coroutines have their own stacks akin to user-space threads. RTOS Tasks look like a closer fit, assuming the preemption is optional and tasks can yield to each other manually.

It's also possible to implement support for specific instruction set and ABI into the fcontext backend directly in assembly. The concept is fairly simple, you just need a way to manipulate the stack pointer and save/restore a few CPU registers to/from the coroutine stacks. (The ontop function is currently unused and can be ignored.)

Klayflash commented 2 years ago

Thanks for the reply.

I've created request on ESP-IDF. So, I think, this ticket can be paused until esp-idf ticket done.