1diff -u old/ new/ 2--- old/Makefile.in 2008-09-18 14:43:55.000000000 -0700 3+++ new/Makefile.in 2008-09-18 14:42:53.000000000 -0700 4@@ -22,10 +22,10 @@ 5 all: dbench tbench tbench_srv 6 7 dbench: $(DB_OBJS) 8- $(CC) -o $@ $(DB_OBJS) $(LIBS) 9+ $(CC) -lpthread -o $@ $(DB_OBJS) $(LIBS) 10 11 tbench: $(TB_OBJS) 12- $(CC) -o $@ $(TB_OBJS) $(LIBS) 13+ $(CC) -lpthread -o $@ $(TB_OBJS) $(LIBS) 14 15 tbench_srv: $(SRV_OBJS) 16 $(CC) -o $@ $(SRV_OBJS) $(LIBS) 17diff -u old/ new/ 18--- old/dbench.c 2008-09-18 14:43:49.000000000 -0700 19+++ new/dbench.c 2008-09-18 14:42:46.000000000 -0700 20@@ -130,6 +130,8 @@ 21 int synccount; 22 struct timeval tv; 23 FILE *load; 24+ int shmid; 25+ sem_t *sema; 26 27 load = open_loadfile(); 28 if (load == NULL) { 29@@ -162,12 +164,24 @@ 30 children[i].directory = directory; 31 } 32 33+ shmid = shmget(IPC_PRIVATE, sizeof(*sema), IPC_CREAT | 0666); 34+ if (shmid < 0) { 35+ perror("could not create shared memory segment"); 36+ exit(1); 37+ } 38+ sema = shmat(shmid, NULL, 0); 39+ 40+ if (sem_init(sema, 1, 0) < 0) { 41+ perror("semaphore initilization failed"); 42+ exit(1); 43+ } 44+ 45 for (i=0;i<nprocs;i++) { 46 if (fork() == 0) { 47 setlinebuf(stdout); 48 nb_setup(&children[i]); 49 children[i].status = getpid(); 50- pause(); 51+ sem_wait(sema); 52 fn(&children[i], loadfile); 53 _exit(0); 54 } 55@@ -185,12 +199,14 @@ 56 57 if (synccount != nprocs) { 58 printf("FAILED TO START %d CLIENTS (started %d)\n", nprocs, synccount); 59+ shmdt(sema); 60 return; 61 } 62 63 printf("%d clients started\n", nprocs); 64 65- kill(0, SIGCONT); 66+ for (i=0;i<nprocs;i++) 67+ sem_post(sema); 68 69 tv_start = timeval_current(); 70 71@@ -202,6 +218,7 @@ 72 if (WEXITSTATUS(status) != 0) { 73 printf("Child failed with status %d\n", 74 WEXITSTATUS(status)); 75+ shmdt(sema); 76 exit(1); 77 } 78 i++; 79@@ -210,6 +227,8 @@ 80 alarm(0); 81 sig_alarm(SIGALRM); 82 83+ shmdt(sema); 84+ 85 printf("\n"); 86 } 87 88diff -u old/ new/ 89--- old/dbench.h 2008-09-18 14:43:48.000000000 -0700 90+++ new/dbench.h 2008-09-18 14:42:48.000000000 -0700 91@@ -35,6 +35,7 @@ 92 #include <sys/ipc.h> 93 #include <sys/shm.h> 94 #include <sys/mman.h> 95+#include <semaphore.h> 96 97 #ifdef HAVE_SYS_VFS_H 98 #include <sys/vfs.h> 99