lua-users home
lua-l archive

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


Adrien de Croy <adrien@qbik.com> writes:

> I'd also query how any subsystem that runs on a pre-empted OS can
> guarantee serialization of calls to a coroutine subsystem without
> binding to a single CPU and running only in a single OS thread (or
> using OS lock primitives).

Look, Lua threads return _values_ to "resume" when "yield"ing.  There
is no way you can have called and called "thread" run simultaneously:
when the caller continues, the callee has _yielded_, and _passed_ a
value to the caller, and vice versa.

Your confusion clearly shows that calling Lua threads "threads" was a
bad idea.  They pass control together with values, so they can't
possibly run simultanously.

To do that, one would have to split "yield" into two: a "yieldvalue"
which gets passed to the calling thread, and a parameterless "yield".
Everything in between could then run in parallel.

I doubt that the complications would make for much usefulness,
however.

-- 
David Kastrup