
Where is the low-level assembly that does the *nuts-and-bolts* of the context switching?
boost.context contains struct fcontext_t storing the architecture+ABI specific stuff (registers) and functions make_fcontext() and jump_fcontext(). The first function is used to set up a fcontext_t and the second one is used to jump from one context to another one. Both functions are written in assembler.
OK. Thanks Oliver. I *really* appreciate what you are doing with context and coroutine. I haven't fully comprehended the depths of your fascinating development, but I sort of get it. I know it's wayyy too late in the game for any top-level requirements. But I would recommend inserting a potentially user-customizable functional element between the context-save and the context-restore. Maybe you already have it and I'm a dummy who can't see it. Do you know why I suggest this? Because we could specialize the functional element to implement a simple (nearly portable) time-slicing cooperative multitasking scheduler simply using a container filled with (coroutine + timer) objects. You already have a yield() function. And I do see some evidence of events and waiting. With a scheduling element and a potential sleep_for() function we could essentially get a robust cooperative multitasking scheduler *right off the rack* from boost. And this is the kind of thing that I, personally, would definitely want to adapt to other architectures. Back in the day, I spent about 5 years, off-and-on writing multitasking schedulers. I eventually ended up at your design---but with scheduling and sleep_for(), but not in the cool boost-way that you have. And these schedulers are still running and being produced in tens of millions of products to this very day.
Template coroutine aggregates two fcontext's. One to store the relevant registers form the calling context and the second struct contains the register stuff of the to called context (coroutines context, coroutine's funtion).
Or am I just totally confused here? Are you doing it in a high-level abstraction that I simply don't understand? Are you using proprocessor macros to do the context switch?
it's assembler code (no inline assembler). Yeah. It's the only way to do it.
Where is the assembler stuff? libs/context/src/asm/...
OK. I Got it. Thanks so much for the clarifications. Well, I need to get back to my other math projects and the pesky day job. I am looking forward to any progress with Boost.Coroutine. Thanks again for this contribution. Best regards, Chris.