Back to index

glibc  2.9
Functions
pthread_rwlock_trywrlock.c File Reference
#include <errno.h>
#include "pthreadP.h"
#include <lowlevellock.h>

Go to the source code of this file.

Functions

int __pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock)

Function Documentation

int __pthread_rwlock_trywrlock ( pthread_rwlock_t *  rwlock)

Definition at line 26 of file pthread_rwlock_trywrlock.c.

{
  int result = EBUSY;

  lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);

  if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
    {
      rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
      result = 0;
    }

  lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);

  return result;
}