5 ms·
Or Go. Or Java' virtual threads. It must happen at the language level; When it comes to execution context knowledge: what context to compile out (stackless), o
by BenoitP 2y ago
Or Go. Or Java' virtual threads.
It must happen at the language level; When it comes to execution context knowledge: what context to compile out (stackless), or what context to serialize to the heap (stackful). Programming language will always know much more about the program than the OS.
If I'm not mistaken in Erlang the programmer will provide the exact context to serialize : the actor.
- josefrichter 2y agoI mentioned the BEAM as “universe” especially because it provides so much more than Go or Java in this respect.
- yencabulator 2y agoThis abstraction that a heap is somehow different than stack is hurting understanding; they're just regions of memory. Go stacks are allocated areas of memory like anything else. When a green thread is suspended, it's stack is not "serialized to the heap". Switching green threads is mostly a question of setting the stack pointer to point to the new green thread's stack. What makes threads "green" is that they are not supposed to call blocking syscalls (they can queue work in a separate blocking threadpool and call the scheduler to suspend themselves). Go has a signal-based mechanism for non-cooperative scheduling of green threads, so green threads are not even required to cooperatively yield to the scheduler.