5 ms·
Mill: Go-style concurrency in C
- loonattic 11y agoWould this be sort of like libthread on Plan 9/plan9port? But a bit nicer? Anyway, really cool project. Though I'm kind of bummed that libthread is as obscure as it is...
- rumcajz 11y agoThe funcionality is more or less the same, however, the API is much more user-friendly than in plan 9. It's stolen from Go after all.
- marktangotango 11y ago>> Though I'm kind of bummed that libthread is as obscure as it is... I am as well. That's the coolest thing about Go imo, Go basically distills down a lot of the coolest stuff from Plan 9, and took it to the 'masses'. Edit; that just my impression, I'm not a Go user. It would be very useful to have syntactic sugar over coroutines and channels in C. There are quiet a few coroutine libs around, but having it in the language would be compelling.
- vezzy-fnord 11y agoEdit; that just my impression, I'm not a Go user. Basically it, I think. Go is the logical evolution of the Limbo language used to write native applications for the Inferno OS, itself evolving from Rob Pike's research with Alef and Newsqueak. The direct heritage spans at least a couple of decades, intermingled with the Plan 9 toolchain and interfaces.
- davidw 11y agoHow's it work under the hood?
- smegel 11y agoGetcontext/setcontext has always allowed for coroutines in C. This just adds a sugar layer of nonblocking functions that allows a runtime layer to switch between contexts (coroutines), just like Go.
- octetta 11y agoThe ucontext stuff is nice but why was it deprecated? It's generally not a problem on x86, but in my experience for other platforms, it gets messy quickly. It would be nice if a replacement or a "de-deprecated" was around.
- Blackthorn 11y agoThat question has seriously bothered me too. OS threads are not a replacement as they are preemptive. The deprecation was way premature.
- tedunangst 11y agomakecontext cannot be correctly represented by the C type system.
- frankerz 11y agoI'm not very good at C, but from my understanding this library uses longjmp functions which means it's cooperative multithreading rather than preemptive isn't it?
- rumcajz 11y agocorrect
- rumcajz 11y agoHere's a short toy implementation of the same principle: http://250bpm.com/blog:48 http://250bpm.com/blog:48
- mikepurvis 11y ago
- verandaguy 11y agoAnyone else getting a malware warning from the site's icon.ico file? Avast's not letting me access it on mac; could someone post a mirror that would get around the issue? Alternatively, can someone confirm/disconfirm that the ico's bad news?
- rumcajz 11y agoYou can check the project directly here: https://github.com/sustrik/mill https://github.com/sustrik/mill
- TehCorwiz 11y agoKaspersky just blocked the whole site for me. EDIT: Looks like it doesn't like http://millc.org/main.css http://millc.org/main.css which is innocuous. >>shrugs<< looks like a false positive.
- rumcajz 11y agoWeird. It's a totally plain CSS file.
- rumcajz 11y agoThere's no icon.ico file there afaics.
- deleted 11y ago[deleted]
- de_Selby 11y agoYeah I'm getting it too, it doesn't like favicon.ico and main.css.
- 314300816905487 11y agorenaldy
- r0nin 11y agoThe name clash with the CPU architecture[1] is by accident? [1] - https://en.wikipedia.org/wiki/Mill_CPU_Architecture https://en.wikipedia.org/wiki/Mill_CPU_Architecture
- skj 11y agoFinally, something that purports to have Go-style concurrency that actually provides the equivalent of select{}! Lots of things just provide chans, which are fancy thread-safe queues and are fairly easy to implement. Getting select{} right is the tricky (and powerful) part.
- rumcajz 11y agoRight, that's one of the main points. The other one is calling invoking C functions as coroutines.
- stefantalpalaru 11y ago> Finally, something that purports to have Go-style concurrency that actually provides the equivalent of select{}! About a week ago I released a library to access Go's channels and goroutines (as implemented by gccgo) from C: https://github.com/stefantalpalaru/golib https://github.com/stefantalpalaru/golib It has Go's runtime select.
- technomancy 11y agoIs this specific to what Go offers, or is it just a CSP implementation? I can't tell from a glance at the page, but let's give credit where credit is due if it's coming from Hoare's ideas.
- rumcajz 11y agoit's CSP as extended by golang, i.e. with channels rather than named processes.
- eternalban 11y agoIs this how the term OO got degenerated? In Communicating Sequential Processes, you only communicate via messages (C) & the processes (P) sequentially (S) run to completion. Go is not CSP. It is fair to say it was inspired by CSP. Go has a preemptive scheduler, and passing shared memory references is idiomatic and at times unavoidable.
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- plg 11y ago$ gcc -o test test.c mill.c mill.c:221:13: error: conflicting types for 'wait' static void wait(int fd, short events) { ^ In file included from /usr/include/stdlib.h:65:0, from mill.c:33: /usr/include/sys/wait.h:248:7: note: previous declaration of 'wait' was here pid_t wait(int *) __DARWIN_ALIAS_C(wait); ^
- IonoclastBrig 11y agoI suppose "choose" was used for multiplexing channel reads to avoid clashing with select(2) (<sys/select.h>) on BSD/POSIX systems..?
- rumcajz 11y agoYep. Same way "case" and "default" cannot be used because they clash with C keywords. I was thinking of using "elect" initially, but that looks too much like a typo.
- glittershark 11y agoI bet this is an absolute nightmare to step through with gdb