lua-users home
lua-l archive

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


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

Fabio Mascarenhas wrote:
[...]
> Obviously I am not married to this solution, so if you have a suggestion
> on how to implement exclusive locks that works both inside the same
> process (even in the same thread) and across processes, for both POSIX
> and Windows, I am all ears. :-)

We did this at work. On Unix our solution was to create a dummy file and
then use advisory locks with fcntl(_, F_SETLKW, _) locking across the
whole file. These have the nice behaviour of being automatically
unlocked if the app terminates unexpectedly. Allegedly these even work
across NFS these days.

For Windows we used named semaphores --- there's an atomic
lookup-by-name-or-create-if-not-found function call. Then you just use
them like an ordinary mutex.

If you want to lock *between* Windows and a Posix subsystem? Pass, I'm
afraid...

- --
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ "They laughed at Newton. They laughed at Einstein. Of course, they
│ also laughed at Bozo the Clown." --- Carl Sagan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpN9iYACgkQf9E0noFvlzgcnACgoXmC4xTGVVSt6ihnwlaR0FU9
fEYAoKwOWTvUmcp43+lYPhC1N1LcN6RV
=atYC
-----END PGP SIGNATURE-----