Fix bug of "pthread_rwlock_timedwrlock" test
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi!
Quoted 8 lines
static
pthread_rwlock_trwlock;
static intthread_state;(quoted diff) +0
-1-static int currsec1, currsec2; static int expired; /* thread_state indicates child thread state:@@ -50,12 +51,14 @@ static int expired; static void* fn(void *arg)
Review static int expired; · line 59
Quoted 10 lines
(quoted diff) +2
-2{ struct timespec abs_timeout; + struct timeval curt; int rc; thread_state = ENTERED_THREAD; /* Absolute time, not relative. */ - abs_timeout.tv_sec = currsec1 - TIMEOUT; - abs_timeout.tv_nsec = 0; + gettimeofday(&curt, NULL);
The time passed to the pthread_rwlock_timedwrlock() should be based on clock_gettime(CLOKC_REALTIME, ...).
Signature · 12 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi!
Quoted 20 lines
/*
thread_stateindicates child thread state:(quoted diff) +9
-2@@ -50,12 +50,30 @@ static int expired; static void* fn(void *arg) { struct timespec abs_timeout; + struct timeval curt; int rc; thread_state = ENTERED_THREAD; /* Absolute time, not relative. */ - abs_timeout.tv_sec = currsec1 - TIMEOUT; - abs_timeout.tv_nsec = 0; +#ifdef CLOCK_REALTIME + rc = clock_gettime(CLOCK_REALTIME, &abs_timeout); + if (rc != 0) + { + printf("Error in clock_gettime(), error code:%d.\n", rc); + exit(PTS_UNRESOLVED); + } + abs_timeout.tv_sec -= TIMEOUT;
Review static int expired; · line 75
Quoted 10 lines
(quoted diff) +10
-0+#else + rc = gettimeofday(&curt, NULL); + if (rc != 0) + { + printf("Error in clock_gettime(), error code:%d.\n", errno); + exit(PTS_UNRESOLVED); + } + abs_timeout.tv_sec = curt.tv_sec - TIMEOUT; + abs_timeout.tv_nsec = curt.tv_usec * 1000; +#endif
Hmm, POSIX says:
All implementations support a clock_id of CLOCK_REALTIME defined in <time.h>.
So the #ifdef part shouldn't be needed. Or there are some problems with undefined CLOCK_REALTIME on your platform?
Signature · 12 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
I've commited a little different fix for this.
Thanks.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Forrester Wave Report - Recovery time is now measured in hours and minutes not days. Key insights are discussed in the 2010 Forrester Wave Report as part of an in-depth evaluation of disaster recovery service providers. Forrester found the best-in-class provider in terms of services and vision. Read this report now! http://p.sf.net/sfu/ibm-webcastpromo _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list