pthread_rwlock_timedwrlock()

lock a read-write lock for writing 

Advanced Realtime Threads


SYNOPSIS

#include <pthread.h>

#include <time.h>

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


DESCRIPTION

The pthread_rwlock_timedwrlock() function applies a write lock to the read-write lock object pointed to by the rwlock argument. This lock is acquired as described in the pthread_rwlock_wrlock() function. However, when such a lock cannot be acquired without waiting for other threads to unlock the lock, the maximum length of that wait is specified by the abs_timeout argument. This argument specifies an absolute time, as measured by the clock on which timeouts are based. Once this time has passed (or if the specified time has already passed at the time of the call, the wait is terminated.

The timeout is based on the system clock as returned by the time() function. The resolution of the timeout is the resolution of the clock on which it is based. The <time.h> header defines the timespec data type. When can be immediately acquired, the abs_timeout argument is ignored.

When a thread blocked on a read-write lock (resulting from a pthread_rwlock_timedwrlock() call) receives a signal that causes a signal handle to be executed, that thread, upon return from the signal handler, resumes waiting for the lock as though 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

abs_timeout 

Specifies the maximum wait for acquiring a lock.

rwlock 

Points to a read-write lock.


RETURN VALUES

On success, the pthread_rwlock_timedwrlock() function returns zero. On failure, it returns one of the following error numbers:

EDEADLK 

The calling thread already holds a write lock on the specified rwlock.

EINVAL 

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

ETIMEDOUT 

The specified timeout expired before the lock could be acquired.


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


PTC MKS Toolkit 10.4 Documentation Build 39.