resistor at mac.com
Thu Jul 24 15:03:48 CDT 2008
On Jul 24, 2008, at 12:30 PM, Álvaro Castro Castilla wrote:
> Sorry for the vagueness.
> I'm starting to think about an experimental programming language
> based, among other things, on microthreads, or green threads, as
> Erlang has. I'm still under a very vague stage, just thinking on it,
> so I was wondering on the way this could be achieved.
> What I know from microthreads are things like:
> * They don't have their own stack
> * Switching between threads is controlled by the application, not
> the OS
These two can be done in C pretty easily. Try googling for
"protothreads" for a library that implements this. To see how it
looks in LLVM, compile it down to bitcode and take a look.
> * They are isolated and the only way to exchange information is
> message passing
This one is hard to guarantee in a compiled context, unless you
implement a lot of stuff to track pointer values. Remember, all of
these threads will be sharing an address space. If you want true
protection, you'll want something more like fork(), but that defeats
your other two goals.
More information about the LLVMdev