Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: GnuPG: gcrypt
Faster mutex lock() and unlock()
 

Index | Next | Previous | View Flat


haypo at inl

Jul 10, 2006, 5:57 AM


Views: 1673
Permalink
Faster mutex lock() and unlock()

Hi,

I would like to know your opinion about replacing old ath_mutex_lock() with:

int
ath_mutex_lock (ath_mutex_t *lock)
{
if (ops_set)
{
return (*ops.mutex_lock) (lock);
}
else
{
#ifndef NDEBUG
assert (*lock == MUTEX_UNLOCKED);
*lock = MUTEX_LOCKED;
#endif
return 0;
}
}

===> remove "int ret = mutex_init (lock, 1);"

Since currently locking a mutex takes 3 mutex operation:
1. lock(check_init_lock) (and then maybe init mutex)
2. unlock(check_init_lock)
3. lock(mutex)

That's heavy and may cost a lot in multithead environment since
check_init_lock is common to all threads.

I can write the patch to remove mutex_init() call in lock() and unlock(),
which means check all lock() and unlock() calls (to check that mutex is
already initialized). But first I would like to know if you prefer very
strong function, or fast function with a big warning :-) (don't call
lock/unlock before initialize them).

Haypo




_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel

Subject User Time
Faster mutex lock() and unlock() haypo at inl Jul 10, 2006, 5:57 AM
    Re: Faster mutex lock() and unlock() marcus.brinkmann at ruhr-uni-bochum Jul 11, 2006, 2:33 AM
    Re: Faster mutex lock() and unlock() haypo at inl Jul 13, 2006, 1:32 AM
    Re: Faster mutex lock() and unlock() nmav at gnutls Jul 13, 2006, 6:40 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.