* Fixed incorrect check: The behavior of pthread_mutex_unlock() is undefined
when called with a default-type mutex owned by another thread. * Automatic whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36294 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fba2ee2527
commit
c25c05da25
@ -2,16 +2,16 @@
|
||||
* Copyright (c) 2002, Intel Corporation. All rights reserved.
|
||||
* Created by: bing.wei.liu REMOVE-THIS AT intel DOT com
|
||||
* This file is licensed under the GPL license. For the full content
|
||||
* of this license, see the COPYING file at the top level of this
|
||||
* of this license, see the COPYING file at the top level of this
|
||||
* source tree.
|
||||
|
||||
* Test that pthread_cond_timedwait()
|
||||
* shall be equivalent to pthread_cond_wait(), except that an error is returned
|
||||
* shall be equivalent to pthread_cond_wait(), except that an error is returned
|
||||
* if the absolute time specified by abstime has already been passed at the time
|
||||
* of the call.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#include <pthread.h>
|
||||
@ -37,14 +37,14 @@ void *t1_func(void *arg)
|
||||
int rc;
|
||||
struct timeval curtime;
|
||||
struct timespec timeout;
|
||||
|
||||
|
||||
if (pthread_mutex_lock(&td.mutex) != 0) {
|
||||
fprintf(stderr,"Thread1 failed to acquire the mutex\n");
|
||||
exit(PTS_UNRESOLVED);
|
||||
}
|
||||
fprintf(stderr,"Thread1 started\n");
|
||||
t1_start = 1; /* let main thread continue */
|
||||
|
||||
|
||||
if (gettimeofday(&curtime, NULL) !=0 ) {
|
||||
fprintf(stderr,"Fail to get current time\n");
|
||||
exit(PTS_UNRESOLVED);
|
||||
@ -85,7 +85,7 @@ int main()
|
||||
return PTS_UNRESOLVED;
|
||||
}
|
||||
|
||||
/* If the thread hasn't ended in 5 seconds, then most probably
|
||||
/* If the thread hasn't ended in 5 seconds, then most probably
|
||||
* pthread_cond_timedwait is failing to function correctly. */
|
||||
alarm(5);
|
||||
|
||||
@ -96,29 +96,24 @@ int main()
|
||||
return PTS_UNRESOLVED;
|
||||
}
|
||||
|
||||
/* Make sure pthread_cond_timedwait released and re-acquired the mutex
|
||||
/* Make sure pthread_cond_timedwait released and re-acquired the mutex
|
||||
* as it should. */
|
||||
rc=pthread_mutex_trylock(&td.mutex);
|
||||
if (rc == 0) {
|
||||
if (rc == 0) {
|
||||
fprintf(stderr,"Test FAILED: Did not re-acquire mutex after timedout out call to pthread_cond_timedwait\n");
|
||||
return PTS_FAIL;
|
||||
}
|
||||
|
||||
if (pthread_mutex_unlock(&td.mutex) != 0) {
|
||||
fprintf(stderr,"Main failed to release mutex\n");
|
||||
return PTS_UNRESOLVED;
|
||||
}
|
||||
|
||||
if(th_ret == PTS_PASS)
|
||||
{
|
||||
printf("Test PASSED\n");
|
||||
printf("Test PASSED\n");
|
||||
return PTS_PASS;
|
||||
}
|
||||
else if(th_ret == PTS_FAIL)
|
||||
{
|
||||
printf("Test FAILED\n");
|
||||
printf("Test FAILED\n");
|
||||
return PTS_FAIL;
|
||||
} else
|
||||
return PTS_UNRESOLVED;
|
||||
return PTS_UNRESOLVED;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user