optimize contended normal mutex case; add int compare-and-swap atomic

This commit is contained in:
Rich Felker committed 2011-03-17 12:14:40 -04:00
1 parent 1d59f1eddb
commit e914f8b7ec
3 files changed
+15 -1

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ int pthread_mutex_trylock(pthread_mutex_t *m)
int tid;
if (m->_m_type == PTHREAD_MUTEX_NORMAL)
return -a_xchg(&m->_m_lock, 1) & EBUSY;
return (m->_m_lock || a_swap(&m->_m_lock, 1)) ? EBUSY : 0;
tid = pthread_self()->tid;