4 ms·
Faster I can believe, but how can custom asm be more portable than setjmp/longjmp which are standard since C89? Although in this particular instance TFA also u
by simias 6y ago
Faster I can believe, but how can custom asm be more portable than setjmp/longjmp which are standard since C89?
Although in this particular instance TFA also uses inline assembly to setup the stack, so it's moot.
- nickelpro 6y agoI'm wrong, I seemed to remember many platforms not supporting them but a quick Google search reveals its just a foggy memory. I was probably thinking about ucontext actually.
- Gibbon1 6y agoMost if not all RTOS's swap threads by saving and restoring the stack and registers. Most of the ones I've seen you can turn off preemption and you then have cooperative threads. It's much easier to deal with shared memory with cooperative threads at the expense of higher latency.
- loeg 6y agoucontext is cursed with the behavior of setting and restoring signal masks with each context switch, involving a kernel syscall. If there was a ucontext-lite standard API that did not mess with signal masks you could cheaply switch green threads in userspace.