1 PTHREAD_RWLOCK_TIMEDWRLOCK(3C)                    Standard C Library Functions
   2 
   3 
   4 
   5 NAME
   6        pthread_rwlock_timedwrlock, pthread_rwlock_reltimedwrlock_np - lock a
   7        read-write lock for writing
   8 
   9 SYNOPSIS
  10        cc -mt [ flag... ] file... [ library... ]
  11        #include <pthread.h>
  12        #include <time.h>
  13 
  14        int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rwlock,
  15             const struct timespec *restrict abs_timeout);
  16 
  17 
  18        int pthread_rwlock_reltimedwrlock_np(pthread_rwlock_t *restrict rwlock,
  19             const struct timespec *restrict rel_timeout);
  20 
  21 
  22 DESCRIPTION
  23        The pthread_rwlock_timedwrlock() function applies a write lock to the
  24        read-write lock referenced by rwlock as in the
  25        pthread_rwlock_wrlock(3C) function. If the lock cannot be acquired
  26        without waiting for other threads to unlock the lock, this wait will be
  27        terminated when the specified timeout expires. The timeout expires when
  28        the absolute time specified by abs_timeout passes, as measured by the
  29        CLOCK_REALTIME clock (that is, when the value of that clock equals or
  30        exceeds abs_timeout), or if the absolute time specified by abs_timeout
  31        has already been passed at the time of the call.
  32 
  33 
  34        The pthread_rwlock_reltimedwrlock_np() function is identical to the
  35        pthread_rwlock_timedwrlock() function, except that the timeout is
  36        specified as a relative time interval. The timeout expires when the
  37        time interval specified by rel_timeout passes, as measured by the
  38        CLOCK_REALTIME clock, or if the time interval specified by rel_timeout
  39        is negative at the time of the call.
  40 
  41 
  42        The resolution of the timeout is the resolution of the CLOCK_REALTIME
  43        clock. The timespec data type is defined in the <time.h>   header.  Under
  44        no circumstances does either function fail with a timeout if the lock
  45        can be acquired immediately. The validity of the abs_timeout parameter
  46        need not be checked if the lock can be immediately acquired.
  47 
  48 
  49        If a signal that causes a signal handler to be executed is delivered to
  50        a thread blocked on a read- write lock with a call to
  51        pthread_rwlock_timedwrlock() or pthread_rwlock_reltimedwrlock_np(),
  52        upon return from the signal handler the thread resumes waiting for the
  53        lock as if it was not interrupted.
  54 
  55 
  56        The calling thread can deadlock if at the time the call is made it
  57        holds the read-write lock. The results are undefined if this function
  58        is called with an uninitialized read-write lock.
  59 
  60 RETURN VALUES
  61        The pthread_rwlock_timedwrlock() and pthread_rwlock_reltimedwrlock_np()
  62        functions return 0 if the lock for writing on the read-write lock
  63        object referenced by rwlock is acquired.  Otherwise, an error number is
  64        returned to indicate the error.
  65 
  66 ERRORS
  67        The pthread_rwlock_timedwrlock() and pthread_rwlock_reltimedwrlock_np()
  68        functions will fail if:
  69 
  70        ETIMEDOUT
  71                     The lock could not be acquired before the specified
  72                     timeout expired.
  73 
  74 
  75 
  76        The pthread_rwlock_timedwrlock() and pthread_rwlock_reltimedwrlock_np()
  77        functions may fail if:
  78 
  79        EDEADLK
  80                   The calling thread already holds the rwlock.
  81 
  82 
  83        EINVAL
  84                   The value specified by rwlock does not refer to an
  85                   initialized read-write lock object, or the timeout
  86                   nanosecond value is less than zero or greater than or equal
  87                   to 1,000 million.
  88 
  89 
  90 ATTRIBUTES
  91        See attributes(5) for descriptions of the following attributes:
  92 
  93 
  94 
  95 
  96        +--------------------+-----------------+
  97        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
  98        +--------------------+-----------------+
  99        |Interface Stability | See below.      |
 100        +--------------------+-----------------+
 101        |MT-Level            | MT-Safe         |
 102        +--------------------+-----------------+
 103 
 104 
 105        The pthread_rwlock_timedwrlock() function is Standard. The
 106        pthread_rwlock_reltimedwrlock_np() function is Stable.
 107 
 108 SEE ALSO
 109        pthread_rwlock_destroy(3C), pthread_rwlock_rdlock(3C),
 110        pthread_rwlock_timedrdlock(3C), pthread_rwlock_trywrlock(3C),
 111        pthread_rwlock_unlock(3C), pthread_rwlock_wrlock(3C), attributes(5),
 112        standards(5)
 113 
 114 
 115 
 116                                January 30, 2004 PTHREAD_RWLOCK_TIMEDWRLOCK(3C)