hi,
The case pthread_cond_init/1-2.c sometimes passed, but sometimes failed on my
box.
OS: RHEL6.1GA x86_64
Memory: 4GB
CPU: Xeon E5506 2.13GHz, 4 cores
When it failed, I got the following messages:
# ./1-2.run-test
Test starting...
Timers option : 200809
Clock Selection option : 200809
Starting clock test
Data initialized successfully for CS test.
Sysconf for monotonix clock: 200809
clock_settime succeeded
Monotonic clock : 200470.244301499
Default clock : 1310609518.800609262
Computed diff : 1310409048.556307763
With monotonic smaller than default
Two threads are created and waiting.
About to change the default clock value.
Checking that both threads have timedout...
The thread was not woken when the clock was changed so as the timeout
expired
Going to simulate this POSIX behavior...
Rechecking that both threads have timedout...
Null attribute cond var timed out
Default attribute cond var did not time out
Default clock was set back using monotonic clock as a reference
Default attribute cond var timedwait return value: 0
Default attribute cond var exited with a timeout : no
Default attribute cond var had to be signaled : yes
Default attribute cond var exited as signaled : yes
Default attribute cond var spurious wakeups : 0
Null attribute cond var timedwait return value: 110
Null attribute cond var exited with a timeout : yes
Null attribute cond var had to be signaled : no
Null attribute cond var exited as signaled : no
Null attribute cond var spurious wakeups : 0
Test ../../../conformance/interfaces/pthread_cond_init/1-2.c FAILED:
The cond vars use different clocks.
I think perhaps it has something to do with the scheduler. The case
calls sched_yield(), which calls __switch() directly in the kernel.
But maybe a very short time later, the main thread is scheduled again,
but not any of the child thread. As a result, sometimes the case passed,
and sometimes failed.
I replace it with sleep(1), and I think 1 second is long enough
to ensure two children threads is scheduled. and now, the case
always passes.
Here is the patch, please comment.:)
Signed-off-by: Tang Chen <[email protected]>
---
.../conformance/interfaces/pthread_cond_init/1-2.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git
a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/1-2.c
b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/1-2.c
index 60ec77b..7f31ca2 100644
---
a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/1-2.c
+++
b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/1-2.c
@@ -371,7 +371,7 @@ int do_cs_test(void)
if (ret != 0) { UNRESOLVED(ret, "Unable to unlock a mutex");
}
/* Let the others threads run */
- sched_yield();
+ sleep(1);
#if VERBOSE > 1
output("Checking that both threads have timedout...\n");
@@ -636,4 +636,4 @@ int main(int argc, char * argv[])
{ FAILED("The cond vars use different clocks."); }
PASSED;
-}
\ No newline at end of file
+}
--
1.7.1
--
Best Regards,
Tang chen
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list