haypo at inl
Jul 10, 2006, 5:57 AM
Faster mutex lock() and unlock()
I would like to know your opinion about replacing old ath_mutex_lock() with:
ath_mutex_lock (ath_mutex_t *lock)
return (*ops.mutex_lock) (lock);
assert (*lock == MUTEX_UNLOCKED);
*lock = MUTEX_LOCKED;
===> 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)
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).
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg