Change how we delete the semaphores to be more FreeBSD friendly. master
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 1 Jan 2013 19:01:15 +0000 (11:01 -0800)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 1 Jan 2013 19:01:15 +0000 (11:01 -0800)
From Richard Sharpe:
Hi Ronnie,

I have been running dbench on FreeBSD (8.0) recently, and I had some
problems getting it to run.

I found that it seems that under FreeBSD, if the semaphore is deleted
(IPC_RMID) before a process returns while waiting on a semop, it can
get EIDRM. I was seeing this for about 30 processes out of 50.

By moving the IPC_RMID out of the child processes and towards the end
of the master, things worked for me.

dbench.c

index 3f2c6c21e482527e6adddde163e9d685a41b126b..1369a381b8203fcfb59ed9e16f878017ae51ee93 100644 (file)
--- a/dbench.c
+++ b/dbench.c
@@ -318,8 +318,6 @@ static void create_procs(int nprocs, void (*fn)(struct child_struct *, const cha
                                exit(1);
                        }
 
-                       semctl(barrier,0,IPC_RMID);
-
                        fn(&children[i*options.clients_per_process], options.loadfile);
                        _exit(0);
                }
@@ -348,8 +346,6 @@ static void create_procs(int nprocs, void (*fn)(struct child_struct *, const cha
                exit(1);
        }
 
-       semctl(barrier,0,IPC_RMID);
-
        signal(SIGALRM, sig_alarm);
        alarm(PRINT_FREQ);
 
@@ -366,6 +362,8 @@ static void create_procs(int nprocs, void (*fn)(struct child_struct *, const cha
        alarm(0);
        sig_alarm(SIGALRM);
 
+       semctl(barrier,0,IPC_RMID);
+
        printf("\n");
 
        report_latencies();