mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-05 21:38:40 +00:00
os/linux: fix rwlock cv waits
This commit is contained in:
@@ -1004,23 +1004,24 @@ os_condition_variable_wait_rw_r(OS_Handle cv, OS_Handle mutex_rw, U64 endt_us)
|
|||||||
endt_timespec.tv_sec = endt_us/Million(1);
|
endt_timespec.tv_sec = endt_us/Million(1);
|
||||||
endt_timespec.tv_nsec = Thousand(1) * (endt_us - (endt_us/Million(1))*Million(1));
|
endt_timespec.tv_nsec = Thousand(1) * (endt_us - (endt_us/Million(1))*Million(1));
|
||||||
B32 result = 0;
|
B32 result = 0;
|
||||||
|
pthread_rwlock_unlock(&rw_mutex_entity->rwmutex_handle);
|
||||||
|
pthread_mutex_lock(&cv_entity->cv.rwlock_mutex_handle);
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&cv_entity->cv.rwlock_mutex_handle);
|
|
||||||
int wait_result = pthread_cond_timedwait(&cv_entity->cv.cond_handle, &cv_entity->cv.rwlock_mutex_handle, &endt_timespec);
|
int wait_result = pthread_cond_timedwait(&cv_entity->cv.cond_handle, &cv_entity->cv.rwlock_mutex_handle, &endt_timespec);
|
||||||
if(wait_result != ETIMEDOUT)
|
if(wait_result != ETIMEDOUT)
|
||||||
{
|
{
|
||||||
pthread_rwlock_rdlock(&rw_mutex_entity->rwmutex_handle);
|
pthread_rwlock_rdlock(&rw_mutex_entity->rwmutex_handle);
|
||||||
pthread_mutex_unlock(&cv_entity->cv.rwlock_mutex_handle);
|
|
||||||
result = 1;
|
result = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&cv_entity->cv.rwlock_mutex_handle);
|
|
||||||
if(wait_result == ETIMEDOUT)
|
if(wait_result == ETIMEDOUT)
|
||||||
{
|
{
|
||||||
|
pthread_rwlock_rdlock(&rw_mutex_entity->rwmutex_handle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&cv_entity->cv.rwlock_mutex_handle);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1039,23 +1040,24 @@ os_condition_variable_wait_rw_w(OS_Handle cv, OS_Handle mutex_rw, U64 endt_us)
|
|||||||
endt_timespec.tv_sec = endt_us/Million(1);
|
endt_timespec.tv_sec = endt_us/Million(1);
|
||||||
endt_timespec.tv_nsec = Thousand(1) * (endt_us - (endt_us/Million(1))*Million(1));
|
endt_timespec.tv_nsec = Thousand(1) * (endt_us - (endt_us/Million(1))*Million(1));
|
||||||
B32 result = 0;
|
B32 result = 0;
|
||||||
|
pthread_rwlock_unlock(&rw_mutex_entity->rwmutex_handle);
|
||||||
|
pthread_mutex_lock(&cv_entity->cv.rwlock_mutex_handle);
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&cv_entity->cv.rwlock_mutex_handle);
|
|
||||||
int wait_result = pthread_cond_timedwait(&cv_entity->cv.cond_handle, &cv_entity->cv.rwlock_mutex_handle, &endt_timespec);
|
int wait_result = pthread_cond_timedwait(&cv_entity->cv.cond_handle, &cv_entity->cv.rwlock_mutex_handle, &endt_timespec);
|
||||||
if(wait_result != ETIMEDOUT)
|
if(wait_result != ETIMEDOUT)
|
||||||
{
|
{
|
||||||
pthread_rwlock_wrlock(&rw_mutex_entity->rwmutex_handle);
|
pthread_rwlock_wrlock(&rw_mutex_entity->rwmutex_handle);
|
||||||
pthread_mutex_unlock(&cv_entity->cv.rwlock_mutex_handle);
|
|
||||||
result = 1;
|
result = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&cv_entity->cv.rwlock_mutex_handle);
|
|
||||||
if(wait_result == ETIMEDOUT)
|
if(wait_result == ETIMEDOUT)
|
||||||
{
|
{
|
||||||
|
pthread_rwlock_wrlock(&rw_mutex_entity->rwmutex_handle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&cv_entity->cv.rwlock_mutex_handle);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user