Skip to contentSkip to conversation

pthread_cond_signal/1-1: fails on routerstation

PATCH In review Kang Kai 2 participants 4 messages Jul 3, 2012 – Jul 12, 2012

lore
Share & tools
lore

Kang Kai

author
#0 lore raw

PATCH 1/1 pthread_cond_signal/1-1: fails on routerstation

Case pthread_cond_signal/1-1 fails on routerstation. The OS is Yocto linux 1.2 with kernel 3.0.24, and c library is eglibc 2.15.

The fail log:
[Thread 0x0x2c56d4b0] started and locked the mutex [Thread 0x0x2c56d4b0] is waiting for the cond [Thread 0x0x2bd6d4b0] started and locked the mutex [Thread 0x0x2bd6d4b0] is waiting for the cond [Thread 0x0x2b56d4b0] started and locked the mutex [Thread 0x0x2b56d4b0] is waiting for the cond
[Main thread] signals a condition
[Thread 0x0x2c56d4b0] was wakened and acquired the mutex again [Thread 0x0x2c56d4b0] released the mutex
[Main thread] 1 waiters were wakened
[Main thread] signals to wake up the next thread [Thread 0x0x2bd6d4b0] was wakened and acquired the mutex again [Thread 0x0x2bd6d4b0] released the mutex
[Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Thread 0x0x2b56d4b0] was wakened and acquired the mutex again [Main thread] had to signal the condition 7 times [Main thread] to wake up 3 threads
. Test FAILED.

The main thread call pthread_cond_signal try to signal the child threads those are waiting on the condition, then call usleep(100) to relinquish the cpu. But 100 useconds is not enough and the main thread continue to run. So the case fails.

Increase the sleep timeto 1000 useconds to make the case pass.

---
 .../interfaces/pthread_cond_signal/1-1.c           |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c +2 -2
index bf55b31..910931d 100644
@@ -142,7 +142,7 @@ int main()
 			fprintf(stderr,"Main failed to signal the condition\n");
 			exit(PTS_UNRESOLVED);
 		}
-		usleep(100);
+		usleep(1000);
 	}
 
 	if (i >= THREAD_NUM) {
@@ -160,4 +160,4 @@ int main()
 	}
 	printf("Test PASSED\n");
 	return PTS_PASS;
-}
\ No newline at end of file
+}
Signature · 13 lines
1.7.5.4


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#1 lore raw
Quoted 53 lines · Kang Kai

Case pthread_cond_signal/1-1 fails on routerstation. The OS is Yocto linux 1.2 with kernel 3.0.24, and c library is eglibc 2.15.

The fail log:
[Thread 0x0x2c56d4b0] started and locked the mutex [Thread 0x0x2c56d4b0] is waiting for the cond [Thread 0x0x2bd6d4b0] started and locked the mutex [Thread 0x0x2bd6d4b0] is waiting for the cond [Thread 0x0x2b56d4b0] started and locked the mutex [Thread 0x0x2b56d4b0] is waiting for the cond
[Main thread] signals a condition
[Thread 0x0x2c56d4b0] was wakened and acquired the mutex again [Thread 0x0x2c56d4b0] released the mutex
[Main thread] 1 waiters were wakened
[Main thread] signals to wake up the next thread [Thread 0x0x2bd6d4b0] was wakened and acquired the mutex again [Thread 0x0x2bd6d4b0] released the mutex
[Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Thread 0x0x2b56d4b0] was wakened and acquired the mutex again [Main thread] had to signal the condition 7 times [Main thread] to wake up 3 threads
. Test FAILED.

The main thread call pthread_cond_signal try to signal the child threads those are waiting on the condition, then call usleep(100) to relinquish the cpu. But 100 useconds is not enough and the main thread continue to run. So the case fails.

Increase the sleep timeto 1000 useconds to make the case pass.

---
  .../interfaces/pthread_cond_signal/1-1.c           |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c +1 -1
index bf55b31..910931d 100644
@@ -142,7 +142,7 @@ int main()
  			fprintf(stderr,"Main failed to signal the condition\n");
  			exit(PTS_UNRESOLVED);
  		}
-		usleep(100);
+		usleep(1000);
  	}
 
  	if (i>= THREAD_NUM) {

testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c int main() · line 163

Quoted 6 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c +1 -1
@@ -160,4 +160,4 @@ int main()
  	}
  	printf("Test PASSED\n");
  	return PTS_PASS;
-}
\ No newline at end of file
+}

Hi,

Could anyone help me to review this patch?
Thanks a lot.

Regards,
Kai

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
In reply to Kang Kai
Quoted 44 lines · Kang Kai

Case pthread_cond_signal/1-1 fails on routerstation. The OS is Yocto linux 1.2 with kernel 3.0.24, and c library is eglibc 2.15.

The fail log:
[Thread 0x0x2c56d4b0] started and locked the mutex [Thread 0x0x2c56d4b0] is waiting for the cond [Thread 0x0x2bd6d4b0] started and locked the mutex [Thread 0x0x2bd6d4b0] is waiting for the cond [Thread 0x0x2b56d4b0] started and locked the mutex [Thread 0x0x2b56d4b0] is waiting for the cond
[Main thread] signals a condition
[Thread 0x0x2c56d4b0] was wakened and acquired the mutex again [Thread 0x0x2c56d4b0] released the mutex
[Main thread] 1 waiters were wakened
[Main thread] signals to wake up the next thread [Thread 0x0x2bd6d4b0] was wakened and acquired the mutex again [Thread 0x0x2bd6d4b0] released the mutex
[Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Thread 0x0x2b56d4b0] was wakened and acquired the mutex again [Main thread] had to signal the condition 7 times [Main thread] to wake up 3 threads
. Test FAILED.

The main thread call pthread_cond_signal try to signal the child threads those are waiting on the condition, then call usleep(100) to relinquish the cpu. But 100 useconds is not enough and the main thread continue to run. So the case fails.

Increase the sleep timeto 1000 useconds to make the case pass.

---
 .../interfaces/pthread_cond_signal/1-1.c           |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c +0 -0
index bf55b31..910931d 100644

testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c int main() · line 145

Quoted 5 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c +1 -1
@@ -142,7 +142,7 @@ int main()
 			fprintf(stderr,"Main failed to signal the condition\n");
 			exit(PTS_UNRESOLVED);
 		}
-		usleep(100);
+		usleep(1000);

Anyway, just add the hard sleep time can resolve nothing. Maybe you can find a better way.

Thanks,
Wanlong Gao

testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c int main() · line 163

Quoted 11 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c +1 -1
 	}
 
 	if (i >= THREAD_NUM) {
@@ -160,4 +160,4 @@ int main()
 	}
 	printf("Test PASSED\n");
 	return PTS_PASS;
-}
\ No newline at end of file
+}

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

author
#3 lore raw
Quoted 40 lines · Wanlong Gao
Quoted 39 lines · Kang Kai

Case pthread_cond_signal/1-1 fails on routerstation. The OS is Yocto linux 1.2 with kernel 3.0.24, and c library is eglibc 2.15.

The fail log:
[Thread 0x0x2c56d4b0] started and locked the mutex [Thread 0x0x2c56d4b0] is waiting for the cond [Thread 0x0x2bd6d4b0] started and locked the mutex [Thread 0x0x2bd6d4b0] is waiting for the cond [Thread 0x0x2b56d4b0] started and locked the mutex [Thread 0x0x2b56d4b0] is waiting for the cond
[Main thread] signals a condition
[Thread 0x0x2c56d4b0] was wakened and acquired the mutex again [Thread 0x0x2c56d4b0] released the mutex
[Main thread] 1 waiters were wakened
[Main thread] signals to wake up the next thread [Thread 0x0x2bd6d4b0] was wakened and acquired the mutex again [Thread 0x0x2bd6d4b0] released the mutex
[Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Main thread] signals to wake up the next thread [Thread 0x0x2b56d4b0] was wakened and acquired the mutex again [Main thread] had to signal the condition 7 times [Main thread] to wake up 3 threads
. Test FAILED.

The main thread call pthread_cond_signal try to signal the child threads those are waiting on the condition, then call usleep(100) to relinquish the cpu. But 100 useconds is not enough and the main thread continue to run. So the case fails.

Increase the sleep timeto 1000 useconds to make the case pass.

---
  .../interfaces/pthread_cond_signal/1-1.c           |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines

testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c int main() · line 145

Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c +1 -1
index bf55b31..910931d 100644
@@ -142,7 +142,7 @@ int main()
  			fprintf(stderr,"Main failed to signal the condition\n");
  			exit(PTS_UNRESOLVED);
  		}
-		usleep(100);
+		usleep(1000);

Hi Wanlong,

Quoted 2 lines

Anyway, just add the hard sleep time can resolve nothing. Maybe you can find a better way.

Thanks for your comment.
I sent a new patch for this issue.
But I still think increase the sleep time is ok. At this point main thread calls usleep() is just want to yield the cpu. For a short sleep time, the kernel may just busy waiting and no schedule happens. Then the child thread doesn't have chance to wake up.
A longer sleep time will ensure the child will be scheduled. And this is the simplest way. :)

Regards,
Kai

Quoted 6 lines

Thanks,
Wanlong Gao

Quoted 2 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c +0 -0
  	}
 
Quoted 11 lines

testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c int main() · line 163

Quoted 9 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_signal/1-1.c +1 -1
  	if (i>= THREAD_NUM) {
@@ -160,4 +160,4 @@ int main()
  	}
  	printf("Test PASSED\n");
  	return PTS_PASS;
-}
\ No newline at end of file
+}

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list