This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: spinlocks


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?)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]