From: Hannu H. <ha...@ik...> - 2011-03-24 19:02:38
|
On 24/03/11 11:18 +0800, Bian Naimeng wrote: > Specifying a passed abs_timeout to pthread_rwlock_timedwrlock. > > Signed-off-by: Bian Naimeng <bi...@cn...> > > --- > .../interfaces/pthread_rwlock_timedwrlock/2-1.c | 7 ++----- > 1 files changed, 2 insertions(+), 5 deletions(-) > > diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_timedwrlock/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_timedwrlock/2-1.c > index b837fac..3ce260c 100644 > --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_timedwrlock/2-1.c > +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_timedwrlock/2-1.c > @@ -34,7 +34,6 @@ > > static pthread_rwlock_t rwlock; > static int thread_state; > -static int currsec1, currsec2; > static int expired; > > /* thread_state indicates child thread state: > @@ -54,7 +53,7 @@ static void* fn(void *arg) > thread_state = ENTERED_THREAD; > > /* Absolute time, not relative. */ > - abs_timeout.tv_sec = currsec1 - TIMEOUT; > + abs_timeout.tv_sec = time(NULL) - TIMEOUT; > abs_timeout.tv_nsec = 0; > > printf("thread: attempt timed write-lock\n"); > @@ -81,8 +80,6 @@ static void* fn(void *arg) > exit(PTS_UNRESOLVED); > } > > - /* Get time after the mutex timed out in locking. */ > - currsec2 = time(NULL); > thread_state = EXITING_THREAD; > pthread_exit(0); > return NULL; > @@ -167,4 +164,4 @@ int main() > > printf("Test PASSED\n"); > return PTS_PASS; > -} > \ No newline at end of file > +} > -- > 1.7.1 > Hi, looks sane to me, you could consider using gettimeofday() just for having a more accuracy by using also tv_usec (microsecs). br, Hannu |