lua-users home
lua-l archive

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


There's not necessarily any locking involved:

- - Lua data structures are sent serialized; they are not modified by separate threads

- - Control of the thread execution (percentage, done, cancelled) can be done in a way that the two threads don't write on same fields. If only one thread writes, and the other reads, there is no need for locking. Or locking is kind of built into the data usage.

I've done similar earlier and I am aware of semaphores etc. in the traditional way (where they rock). Walking on thin ice here, but thanks for the warning! ;)

- -asko


There's a minimal critical section

Javier Guerra kirjoitti 8.2.2007 kello 21.41:

On Thursday 08 February 2007, Asko Kauppi wrote:
You don't need to dive into OS specific issues, at all. Threads share
a common address space, so all you have to do is serialize Lua data
structures into a stream (allocated char array), deserialize it in
the other thread. I would definately see a need for this + basic
thread creation (portable) + lazy evaluation, all together in an easy
to use package.

what would be easier: writing a thin portable layer over pthreads/ winthreads, or discovering the hard way that you shouldn't modify the same structure on
two threads and reinventing semaphores?

--
Javier

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFFy/gyGJtHlJZfjQoRAk4JAKCQalQ/Q1W+vF3puoytr4KoIhPJwQCgiD5J
EMHSK98T3Huedjon8EC+76g=
=sSxV
-----END PGP SIGNATURE-----