Show HN: Libconcurrent – Coroutines in C
github.com
Show HN: Libconcurrent – Coroutines in C
1–10 of 26 posts
Re: Show HN: Libconcurrent – Coroutines in C
#2Re: Show HN: Libconcurrent – Coroutines in C
#3A 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.")
Re: Show HN: Libconcurrent – Coroutines in C
#4Is this statement basically a do while/while(true) infinite loop?
for (;;) {
...
}Re: Show HN: Libconcurrent – Coroutines in C
#5I got a silly question: Is this statement basically a do while/while(true) infinite loop? for (;;) { ... }
Lots of people do it because stupid C compilers produce better code for `for(;;)` than they do for `while(1)` and stupid C compilers used to be very common.
It's also one less character spent: A rare win/win.
Re: Show HN: Libconcurrent – Coroutines in C
#6I got a silly question: Is this statement basically a do while/while(true) infinite loop? for (;;) { ... }
Re: Show HN: Libconcurrent – Coroutines in C
#7I got a silly question: Is this statement basically a do while/while(true) infinite loop? for (;;) { ... }
Yes. You're likely to run into this construct often in C. Lots of people do it because stupid C compilers produce better code for `for(;;)` than they do for `while(1)` and stupid C compilers used to be very common. It's also one less character spent: A rare win/win.
I am really interested in learning some C however, especially after this post hit front page a few days ago:
Re: Show HN: Libconcurrent – Coroutines in C
#8Re: Show HN: Libconcurrent – Coroutines in C
#9The links to other projects with similar goals at the bottom of the Readme is brilliant. It helps developers solve their problems irrespective of whether this particular solution works...and solving problems not stars and forks is the measure of utility for a library.
There's a link to the .h file near the bottom of the page.
That technique is what's used in protothreads and Contiki OS.
Re: Show HN: Libconcurrent – Coroutines in C
#10Cool! 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.")
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.