lua-users home
lua-l archive

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


On Mon, 24 Sep 2001, Joshua Jensen wrote:

> In lstate.c, the following comment exists:
>
> ** macros for thread syncronization inside Lua core machine:
> ** all accesses to the global state and to global objects are
> syncronized.
> ** Because threads can read the stack of other threads
> ** (when running garbage collection),
> ** a thread must also syncronize any write-access to its own stack.
> ** Unsyncronized accesses are allowed only when reading its own stack,
> ** or when reading immutable fields from global objects
> ** (such as string values and udata values).
>
> Exactly what does it mean to "synchronize any write-access to its own
> stack"?

It means that a thread can write to its onw stack only when it has the lock.
If it will only read the stack, it does not need the lock, as no other
thread can write to that stack.

-- Roberto