Hacker News new | ask | show | jobs
by geofft 3815 days ago
Cool!

A co-TA and I ported the concurrency library in JOS, MIT's teaching operating system, to regular UNIX:

https://github.com/geofft/vireo

It uses the standard-ish library functions setcontext and getcontext to avoid an assembly dependency. ("POSIX.1-2008 removes the specification of getcontext(), citing portability issues, and recommending that applications be rewritten to use POSIX threads instead.")

1 comments

*context are unfortunately quite slow as they require a system call to update the signal mask. The sigaltstack trick popularized by Pth is probably still more portable and faster.

BTW makecontext and friend were made obsolete by posix for a technicality: makecontext signature isn't expressible any longer in a strictly conforming C99 applications, although in practice it will work with any C compiler.

Ironically this happened around the same time that coroutines started becoming popular again.