lua-users home
lua-l archive

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

Hugo Etchegoyen <> writes:

> IMHO a non-preemptible thread and a coroutine (at least the kind of
> coroutines you are talking about, which have a private stack) are
> the same thing.

This would hold at best on single processors: on multiple processors,
several threads can run simultaneously unpreempted.  However,
coroutines, being strictly synchronized, can have something that
threads in general don't: they can pass values.  Yielding in a Lua
thread will both pass and accept a value to and from the controlling
Lua thread.  This is obviously only possible when the caller is
suspended until the called thread yields.  Apart from the switching of
the stacks, this is completely identical to function calls.

David Kastrup