Hi !

Fix concurrency issue in msgrcv05. Due to the use of usleep function to
synchronize processes, synchronization issues can occur on a loaded
system. Fix this by using pipes to synchronize processes.

Signed-off-by: Matthieu Fertré <[EMAIL PROTECTED]>

R.

-- 
Renaud Lottiaux

Kerlabs
Bâtiment Germanium
80, avenue des buttes de Coësmes
35700 Rennes - France
Phone : (+33|0)6 80 89 19 34
Fax   : (+33|0)2 99 84 71 71
Email : [EMAIL PROTECTED]
Web   : http://www.kerlabs.com/
Index: cvs/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
===================================================================
--- cvs.orig/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c	2008-03-28 14:54:26.000000000 +0100
+++ cvs/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c	2008-03-28 15:09:04.000000000 +0100
@@ -46,6 +46,10 @@
  *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
+ *      14/03/2008 Matthieu Fertré ([EMAIL PROTECTED])
+ *      - Fix concurrency issue. Due to the use of usleep function to
+ *        synchronize processes, synchronization issues can occur on a loaded
+ *        system. Fix this by using pipes to synchronize processes.
  *
  * RESTRICTIONS
  *	none
@@ -82,6 +86,7 @@
 {
 	int lc;				/* loop counter */
 	char *msg;			/* message returned from parse_opts */
+	int sync_pipes[2];
 
 	/* parse standard options */
 	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
@@ -94,6 +99,10 @@
 
 	setup();			/* global setup */
 
+	if (create_sync_pipes(sync_pipes) == -1) {
+		tst_brkm(TBROK, cleanup, "cannot create sync pipes");
+	}
+
 	/* The following loop checks looping state if -i option given */
 
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -113,6 +122,11 @@
 			 * Attempt to read a message without IPC_NOWAIT.
 			 * With no message to read, the child sleeps.
 			 */
+
+			if (notify_startup(sync_pipes) == -1) {
+				tst_brkm(TBROK, cleanup, "notify_startup failed");
+			}
+
 #ifdef UCLINUX
 			if (self_exec(av[0], "d", msg_q_1) < 0) {
 				tst_brkm(TBROK, cleanup, "could not self_exec");
@@ -121,7 +135,15 @@
 			do_child();
 #endif
 		} else {			/* parent */
-			usleep(250000);
+
+			if (wait_son_startup(sync_pipes) == -1) {
+				tst_brkm(TBROK, cleanup, "wait_son_startup failed");
+			}
+			/* After son has been created, give it a chance to execute the
+			 * msgrcv command before we continue. Without this sleep, on SMP machine
+			 * the father kill could be executed before the son msgrcv.
+			 */
+			sleep(1);
 
 			/* send a signal that must be caught to the child */
 			if (kill(c_pid, SIGHUP) == -1) {
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to