]> git.saurik.com Git - apple/libc.git/blobdiff - pthreads/pthread_cond_timedwait.3
Libc-594.9.1.tar.gz
[apple/libc.git] / pthreads / pthread_cond_timedwait.3
index 3ff427d9b31d74a74d00f5d68c1d0272082d746a..dbf48e429e29ce0c56b9006e5738020944e1e3e6 100644 (file)
 .Sh SYNOPSIS
 .Fd #include <pthread.h>
 .Ft int
-.Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime"
+.Fo pthread_cond_timedwait
+.Fa "pthread_cond_t *restrict cond"
+.Fa "pthread_mutex_t *restrict mutex"
+.Fa "const struct timespec *restrict abstime"
+.Fc
 .Sh DESCRIPTION
 The
 .Fn pthread_cond_timedwait
 function atomically blocks the current thread waiting on the condition
 variable specified by
-.Fa cond ,
+.Fa cond
 and unblocks the mutex specified by
 .Fa mutex .
 The waiting thread unblocks only after another thread calls
@@ -54,11 +58,28 @@ time specified in
 .Fa abstime ,
 and the current thread reacquires the lock on
 .Fa mutex .
+.Pp 
+Values for struct timespec can be obtained by adding the required
+time interval to the  the current time obtained using 
+.Xr gettimeofday 2 .
+.Pp
+.Fa Note 
+that struct timeval and struct timespec use different units to specify
+the time. Hence, the user should always take care to perform the time unit 
+conversions accordingly.
+.Sh EXAMPLE
+.Pp
+   struct timeval tv;
+   struct timespec ts;
+   gettimeofday(&tv, NULL);
+   ts.tv_sec = tv.tv_sec + 0;
+   ts.tv_nsec = 0;
+.Pp
 .Sh RETURN VALUES
 If successful, the
 .Fn pthread_cond_timedwait
 function will return zero.
-Otherwise an error number will be returned to
+Otherwise, an error number will be returned to
 indicate the error.
 .Sh ERRORS
 .Fn pthread_cond_timedwait
@@ -80,7 +101,8 @@ The system time has reached or exceeded the time specified in
 .Xr pthread_cond_destroy 3 ,
 .Xr pthread_cond_init 3 ,
 .Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_wait 3
+.Xr pthread_cond_wait 3 ,
+.Xr gettimeofday 2
 .Sh STANDARDS
 .Fn pthread_cond_timedwait
 conforms to