Hi !

Fix concurrency issue in semop05. 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/semop/semop05.c
===================================================================
--- cvs.orig/testcases/kernel/syscalls/ipc/semop/semop05.c	2008-03-28 14:54:25.000000000 +0100
+++ cvs/testcases/kernel/syscalls/ipc/semop/semop05.c	2008-03-28 15:13:19.000000000 +0100
@@ -51,12 +51,18 @@
  *
  * 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
  */
 
 #include "ipcsem.h"
+#include "libtestsuite.h"
+
 #include <sys/types.h>
 #include <sys/wait.h>
 
@@ -123,6 +129,11 @@
 		Tst_count = 0;
 
 		for (i=0; i<TST_TOTAL; i++) {
+			int sync_pipes[2];
+
+			if (create_sync_pipes(sync_pipes) == -1) {
+				tst_brkm(TBROK, cleanup, "cannot create sync pipes");
+			}
 
 			/* initialize the s_buf buffer */
 			s_buf.sem_op = TC[i].op;
@@ -140,6 +151,11 @@
 			}
 
 			if (pid == 0) {		/* child */
+
+				if (notify_startup(sync_pipes) == -1) {
+					tst_brkm(TBROK, cleanup, "notify_startup failed: %d", errno);
+				}
+
 #ifdef UCLINUX
 				if (self_exec(av[0], "dd", i, sem_id_1) < 0) {
 					tst_brkm(TBROK, cleanup,
@@ -149,7 +165,15 @@
 				do_child(i);
 #endif
 			} else {		/* parent */
-				usleep(250000);
+
+				if (wait_son_startup(sync_pipes) == -1) {
+					tst_brkm(TBROK, cleanup, "wait_son_startup failed: %d", errno);
+				}
+				/* After son has been created, give it a chance to execute the
+				 * semop command before we continue. Without this sleep, on SMP machine
+				 * the father rm_sema/kill could be executed before the son semop.
+				 */
+				sleep(1);
 
 				/*
 				 * If we are testing for EIDRM then remove
Index: cvs/testcases/kernel/syscalls/ipc/semop/Makefile
===================================================================
--- cvs.orig/testcases/kernel/syscalls/ipc/semop/Makefile	2008-03-28 14:54:25.000000000 +0100
+++ cvs/testcases/kernel/syscalls/ipc/semop/Makefile	2008-03-28 15:12:37.000000000 +0100
@@ -16,8 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+CFLAGS += -I../lib -I../../lib -I../../../../../include -Wall
+LDLIBS += -L../../../../../lib -lltp -L.. -lipc -L../.. -ltestsuite
 
 SRCS    = $(wildcard *.c)
 TARGETS = $(patsubst %.c,%,$(SRCS))
-------------------------------------------------------------------------
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