-- Leo's gemini proxy

-- Connecting to gemini.tuxmachines.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;lang=en-GB

Tux Machines


Christian Hergert: Threading Fibers


Posted by Roy Schestowitz on Dec 13, 2022


Android Leftovers

13 Best Free and Open Source Linux Video Editors


↺ GNOME Asia


Previously on Futures, Work-Stealing, and such.


One thing I admired during the early days of Python Twisted was how it took advantage of the language to write asynchronous code which read as synchronous. Pretty much all the modern languages now have some form of this in stackless or stackfull form.


C has been able to do it for ages but it generally doesn’t play well outside of constrained applications. The primary things you have to worry about are functional tooling like debuggers (thread apply all bt wont show you all your fibers) and features like thread-local-storage.


If you’re careful about when you suspend your fiber, the later isn’t so much of an issue. Where it can become a serious issue is if you do something like call an intermediate function which uses callbacks and the callback suspends. In this case, the intermediate function (out of your control) might have some TLS state cached on the stack, which of course could be modified before resume is called.


But either way, dex (wip title newlib) has support for fibers now which can be spawned using dex_scheduler_spawn(). Fiber stacks are given a guard page so that stack overflows are still guarded. It tries to do a bit of madvise() when it makes sense to.


Read on


↺ Read On: Gnome


Also: GNOME Asia Feels


↺ GNOME Asia Feels




gemini.tuxmachines.org

-- Response ended

-- Page fetched on Sat Jun 1 08:50:26 2024