implement robust mutexes
some of this code should be cleaned up, e.g. using macros for some of the bit flags, masks, etc. nonetheless, the code is believed to be working and correct at this point.
This commit is contained in:
parent
18c7ea8055
commit
047e434ef5
10 changed files with 84 additions and 10 deletions
|
|
@ -4,9 +4,9 @@ int pthread_mutex_lock(pthread_mutex_t *m)
|
|||
{
|
||||
int r;
|
||||
while ((r=pthread_mutex_trylock(m)) == EBUSY) {
|
||||
if (!(r=m->_m_lock)) continue;
|
||||
if (m->_m_type == PTHREAD_MUTEX_ERRORCHECK
|
||||
&& r == pthread_self()->tid)
|
||||
if (!(r=m->_m_lock) || (r&0x40000000)) continue;
|
||||
if ((m->_m_type&3) == PTHREAD_MUTEX_ERRORCHECK
|
||||
&& (r&0x1fffffff) == pthread_self()->tid)
|
||||
return EDEADLK;
|
||||
__wait(&m->_m_lock, &m->_m_waiters, r, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue