spinlocks
Matthew Wilcox
willy@ldl.fc.hp.com
Thu Apr 26 16:41:00 GMT 2001
On Wed, Apr 25, 2001 at 11:34:03PM -0700, Ulrich Drepper wrote:
> - the name _lt_spinlock_t isn't good. We already have too many spinlocks.
> I'd suggest rather something in the line of __lock_object_t or so (better
> proposals are welcome). The initializer will have to be renamed
> appropriately.
How about __atomic_lock_t ? Agreed to renaming the initialiser. Can I rename
testandset() too? I'd prefer it to be try_lock(). I wonder what to call
test()... lock_held() ? That way the code looks like:
__atomic_lock_t my_lock = __ATOMIC_LOCK_INIT;
foo()
{
while (try_lock(&my_lock)) ;
...
release_lock(&my_lock);
}
bar()
{
if (lock_held(&my_lock))
{
...
}
}
release_lock() is, of course simply:
#define release_lock(x) *x = __ATOMIC_LOCK_INIT;
(possibly static inline for greater type-safety?)
More information about the Libc-alpha
mailing list