lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Edgar Toernig wrote:
[...]
Yes, I know them.  Unfortunately, they are not widely available.
I.e. not on my system and afaik not under Windows either.

I do know they're not available under Cygwin, but they're trivially emulateable using some core Windows APIs (Google for 'ucontext windows'). However, I'm pretty firmly stuck in the Unix world, and they seem to be pretty standard there...

The major downside I see with the ucontext functions is that they
perform system calls during swapcontext (to change signal masks).
Performance goes down the drain...

Okay, I can see that. I haven't really noticed anything, but I'm not doing context switches at any great rate.

[...]
The setup_jmpbuf function I posted earlier is the absolutely
minimal code[1] required to implement coroutines or userspace
threads.  I.e. an implementation of the ucontext functions with
all features required for Lua comes down to this:

I'll remember that, if you don't mind --- it might come in rather handy. (Frex, I've just had someone complain that Spey doesn't build under Cygwin. As I'm not using signals, this might be just the thing I was looking for...)

--
[insert interesting .sig here]