3 ms·
Actually, green threads are much faster at context switching than native threads. They also consume less heap space for (if it's growable) stack. Native thread
by tomp 12y ago
Actually, green threads are much faster at context switching than native threads. They also consume less heap space for (if it's growable) stack.
Native threads are natively supported by the OS, so managing them requires calls to the OS, the main reason why it's slow. However, it comes with a few advantages. The main advantage of native threads is that they are preemptive - they can be scheduled based on ticks (i.e. number of microseconds spent running the thread), even if they are in the middle of a loop. Also, they can be run on different CPUs, the OS takes care of all CPU flags/registers/etc., they are actual OS structures, ...
- MichaelGG 12y agoDo other OSes have an equivalent to User Mode Scheduling? It seems to allow you to get the best of both worlds, if your tasks are amenable to the model. http://msdn.microsoft.com/en-us/library/windows/desktop/dd627187(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/dd62...
- erickt 12y agoGoogle supposedly has implemented something similar called user-level threads, which they talked about at the 2013 Linux Plumbers Conference. If I recall the video correctly, they talk about plans to open source it, but as far as I know there hasn't been much movement in that space yet: http://www.linuxplumbersconf.org/2013/ocw/proposals/1653 http://www.linuxplumbersconf.org/2013/ocw/proposals/1653 https://www.youtube.com/watch?v=KXuZi9aeGTw https://www.youtube.com/watch?v=KXuZi9aeGTw