pthread_rwlock_timedrdlock()

lock a read-write lock for reading 

Advanced Realtime Threads


SYNOPSIS

#include <pthread.h>

#include <time.h>

int pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rwlock, const struct timespec *restrict abs_timeout);


DESCRIPTION

The pthread_rwlock_timedrdlock() function applies a read lock to the read-write lock pointed to by rwlock in a similar manner to the pthread_rwlock_rdlock() function. However, if acquiring this lock requires waiting for other threads to unlock it, pthread_rwlock_timedrdlock() only waits until the specified timeout expires. The timeout expires when the absolute time specified by the abs_timeout argument passes, as measured by the clock on which timeouts are based (that is, when the value of that clock equals or exceeds abs_timeout), or if the absolute time specified by abs_timeout has already been passed at the time of the call.

The timeout is based on the system clock as returned by the time() function. The resolution of the timeout shall be the resolution of the clock on which it is based. The <time.h> header defines the timespec data type.

When pthread_rwlock_timedrdlock() can acquire a lock immediately, it does not check the validity of abs_timeout, and thus, can never fail with a timeout in such a circumstance.

When a thread blocked on a read-write lock via a pthread_rwlock_timedrdlock() call receives a signal that causes a signal handler to be executed, that thread, upon return from the signal handler, resumes waiting for the lock as if no interruption occurred.

The calling thread may detect a deadlock (and return EDEADLK) if at the time the call is made it holds a write lock.


PARAMETERS

rwlock 

Points to a read-write lock.

abs_timeout 

Specifies how long the pthread_rwlock_timedlock() function should wait to acquire a lock.


RETURN VALUES

On success, the pthread_rwlock_timedrdlock() function acquires a lock for reading on rwlock and returns zero. On failure, it returns one of the following error numbers:

EAGAIN 

Acquiring the read lock would exceed the maximum number of read locks allowed.

EDEADLK 

The calling thread already holds a write lock on rwlock.

EINVAL 

The value specified by rwlock does not refer to an initialized read-write lock object, or the abs_timeout value is invalid.

ETIMEDOUT 

The lock could not be acquired before the specified timeout expired.


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_timedwrlock(), pthread_rwlock_tryrdlock(), pthread_rwlock_trywrlock(), pthread_rwlock_unlock(), pthread_rwlock_wrlock()


PTC MKS Toolkit 10.5 Documentation Build 40.