Beispiel #1
0
DLL_EXPORT int ptt_pthread_mutex_unlock(LOCK *mutex, char *loc)
{
int result;
    result = fthread_mutex_unlock(mutex);
    PTTRACE ("unlock", mutex, NULL, loc, result);
    return result;
}
Beispiel #2
0
int fthread_cond_wait(fthread_cond_t *cond, fthread_mutex_t *mutex) {
  if (cond->__waitm) {
    /* there should only be one mutex being used for concurrent
       waits on a single condition variable */
    if (cond->__waitm != mutex) {
      return EINVAL;
    }
  } else {
    cond->__waitm = mutex;
  }
  /* we also need to own the mutex */
  int err = fthread_mutex_unlock(mutex);
  if (err) {
    return err;
  }

  /* can't destroy a mutex while it's being used in a cond_wait:
   * have to up the use count so any calls to destroy will fail with
   * EBUSY */
  mutex->__usecount++;
  cond->__usecount++;
  sched_sleep_on(&cond->__waitq);
  fthread_mutex_lock(mutex);
  mutex->__usecount--;
  cond->__usecount--;
  return 0;
}