Commit 4b6d8c81 authored by Antonia Francis's avatar Antonia Francis
Browse files

* Adjust semantics for pthread_mutex_trylock()

parent f3931276
...@@ -115,11 +115,10 @@ int __po_hi_sem_wait(__po_hi_sem_t* sem) ...@@ -115,11 +115,10 @@ int __po_hi_sem_wait(__po_hi_sem_t* sem)
{ {
#if defined (RTEMS_POSIX) || defined (POSIX) || defined (XENO_POSIX) #if defined (RTEMS_POSIX) || defined (POSIX) || defined (XENO_POSIX)
/* Locking the mutex */ /* Locking the mutex */
if (pthread_mutex_trylock(&sem->mutex.posix_mutex) != 0 ) if (pthread_mutex_trylock(&sem->mutex.posix_mutex) == 0 ) {
{ pthread_mutex_lock(&sem->mutex.posix_mutex);
__PO_HI_DEBUG_CRITICAL ("[SEMAPHORE] Error when trying to trylock mutex\n");
return __PO_HI_ERROR_SEM_WAIT;
} }
/* Waiting on a condition and unlocking the mutex while doing so */ /* Waiting on a condition and unlocking the mutex while doing so */
if (pthread_cond_wait(&sem->posix_condvar, &sem->mutex.posix_mutex) != 0 ) if (pthread_cond_wait(&sem->posix_condvar, &sem->mutex.posix_mutex) != 0 )
{ {
...@@ -168,6 +167,7 @@ int __po_hi_sem_wait(__po_hi_sem_t* sem) ...@@ -168,6 +167,7 @@ int __po_hi_sem_wait(__po_hi_sem_t* sem)
EnterCriticalSection(&sem->win32_criticalsection); EnterCriticalSection(&sem->win32_criticalsection);
#endif #endif
return __PO_HI_SUCCESS; return __PO_HI_SUCCESS;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment