pthread_rwlock_trywrlock(), pthread_rwlock_wrlock()

lock a read-write lock object for writing 

Advanced Realtime Threads


SYNOPSIS

#include <pthread.h>

int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);

int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);


DESCRIPTION

The pthread_rwlock_trywrlock() function applies a write lock in a manner similar to the pthread_rwlock_wrlock() function, except that the function fails if any thread currently holds rwlock (for reading or writing).

The pthread_rwlock_wrlock() function applies a write lock to the read-write lock object pointed to by the rwlock arugument. This lock is not acquired when a thread already holds the read-write lock rwlock. In this case, the calling thread blocks unitl it is able to acquire the lock. If the calling thread already owns the write lock when this function is called, the thread may detect a deadlock (and return EDEADLK).

To avoid writer starvation, writers are favored over readers. Readers block while writers are waiting and writers have a greater probability of waking up once blocked.

When a thread waiting to acquire a write lock receives a signal, that thread, upon return from the signal handler, resumes waiting as though no interruption occurred.


PARAMETERS

rwlock 

Points to a read-write lock object.


RETURN VALUES

On success, the pthread_rwlock_trywrlock() pthread_rwlock_wrlock() functions return zero. On failure, they return one of the following error numbers:

EBUSY 

A write lock was unable to be acquired because rwlock was already locked for reading or writing.

EDEADLK 

The current thread already owns the read-write lock for writing.

EINVAL 

The rwlock argument does not point to an initialized read-write lock object.


CONFORMANCE

UNIX 03.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
pthread_rwlock_destroy(), pthread_rwlock_rdlock(), pthread_rwlock_timedrdlock(), pthread_rwlock_timedwrlock(), pthread_rwlock_tryrdlock(), pthread_rwlock_unlock()


PTC MKS Toolkit 10.3 Documentation Build 39.