lua-users home
lua-l archive

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


On Mon, Mar 20, 2006 at 11:08:15AM -0700, jdarling@eonclash.com wrote:
> This was of course why I mentioned spin locks as they are supported
> at the processor level and (from what I have read and used)

One issue with spin locks is if that if you've only got a single CPU,
then when there is contention the process that needs the lock will end
up spinning for its entire time slice.  This time would probably be
better spent rescheduling the lock holder so that it can finish up its
work and release the lock.

> are much faster then software or OS level locking mechs.

System call overhead can certainly be a problem if you're doing a lot
of locking operations.  In the case of Linux there's a "futex" locking
mechanism that only requires a system call when the lock is actually
contended.  I'm pretty sure NPTL, the latest POSIX threading
implementation on Linux, is built around futexes.

                                                  -Dave Dodge