@@ -29,6 +29,8 @@
#define NRPROC (128)
#define NRLOCK (10240)
+#define TFR TEMP_FAILURE_RETRY
+
static struct timespec *diff;
static int
@@ -84,7 +86,8 @@ usage(char *prog)
int
main(int argc, char **argv)
{
- int i, opt, valid = 0;
+ int i, c, opt, valid = 0;
+ int to_lockers[2];
int nproc = NRPROC;
int nlock = NRLOCK;
pid_t *pids;
@@ -123,11 +126,28 @@ main(int argc, char **argv)
return 1;
}
+ if (pipe(to_lockers)) {
+ fprintf(stderr, "pipe (to_lockers)");
+ return 1;
+ }
+
for (i = 0; i < nproc; ++i) {
pids[i] = fork();
- if (!pids[i])
+ if (!pids[i]) {
+ while (TFR(read(to_lockers[0], &c, 1)) != 1)
+ ;
return lockunlock(argv[optind], nlock, &diff[i]);
+ }
+ }
+
+ close(to_lockers[0]);
+ for (i = 0; i < nproc; ++i) {
+ if (TFR(write(to_lockers[1], &c, 1)) != 1) {
+ perror("write child");
+ return 1;
+ }
}
+ close(to_lockers[1]);
for (i = 0; i < nproc; ++i) {
int status;
@@ -30,6 +30,8 @@
#define NRPROC (128)
#define NRLOCK (20480)
+#define TFR TEMP_FAILURE_RETRY
+
static struct timespec *diff;
static int
@@ -91,7 +93,8 @@ usage(char *prog)
int
main(int argc, char **argv)
{
- int i, opt, valid = 0;
+ int i, c, opt, valid = 0;
+ int to_lockers[2];
int nproc = NRPROC;
int nlock = NRLOCK;
pid_t *pids;
@@ -142,11 +145,28 @@ main(int argc, char **argv)
return 1;
}
+ if (pipe(to_lockers)) {
+ fprintf(stderr, "pipe (to_lockers)");
+ return 1;
+ }
+
for (i = 0; i < nproc; ++i) {
pids[i] = fork();
- if (!pids[i])
+ if (!pids[i]) {
+ while (TFR(read(to_lockers[0], &c, 1)) != 1)
+ ;
return lockunlock(nlock, &diff[i]);
+ }
+ }
+
+ close(to_lockers[0]);
+ for (i = 0; i < nproc; ++i) {
+ if (TFR(write(to_lockers[1], &c, 1)) != 1) {
+ perror("write child");
+ return 1;
+ }
}
+ close(to_lockers[1]);
for (i = 0; i < nproc; ++i) {
int status;
@@ -30,6 +30,8 @@
#define NRPROC (128)
#define NRLOCK (10240)
+#define TFR TEMP_FAILURE_RETRY
+
static struct timespec *diff;
static int
@@ -97,7 +99,8 @@ int
main(int argc, char **argv)
{
bool verbose = false, yield = false;
- int i, opt, valid = 0;
+ int i, c, opt, valid = 0;
+ int to_lockers[2];
int nproc = NRPROC;
int nlock = NRLOCK;
pid_t *pids;
@@ -142,12 +145,29 @@ main(int argc, char **argv)
return 1;
}
+ if (pipe(to_lockers)) {
+ fprintf(stderr, "pipe (to_lockers)");
+ return 1;
+ }
+
for (i = 0; i < nproc; ++i) {
pids[i] = fork();
- if (!pids[i])
+ if (!pids[i]) {
+ while (TFR(read(to_lockers[0], &c, 1)) != 1)
+ ;
return lockunlock(argv[optind], nlock,
&diff[i], verbose, yield);
+ }
+ }
+
+ close(to_lockers[0]);
+ for (i = 0; i < nproc; ++i) {
+ if (TFR(write(to_lockers[1], &c, 1)) != 1) {
+ perror("write child");
+ return 1;
+ }
}
+ close(to_lockers[1]);
for (i = 0; i < nproc; ++i) {
int status;
@@ -29,6 +29,8 @@
#define NRPROC (128)
#define NRLOCK (20480)
+#define TFR TEMP_FAILURE_RETRY
+
static struct timespec *diff;
static int
@@ -93,7 +95,8 @@ usage(char *prog)
int
main(int argc, char **argv)
{
- int i, opt, valid = 0;
+ int i, c, opt, valid = 0;
+ int to_lockers[2];
int nproc = NRPROC;
int nlock = NRLOCK;
pid_t *pids;
@@ -144,11 +147,28 @@ main(int argc, char **argv)
return 1;
}
+ if (pipe(to_lockers)) {
+ fprintf(stderr, "pipe (to_lockers)");
+ return 1;
+ }
+
for (i = 0; i < nproc; ++i) {
pids[i] = fork();
- if (!pids[i])
+ if (!pids[i]) {
+ while (TFR(read(to_lockers[0], &c, 1)) != 1)
+ ;
return lockunlock(nlock, &diff[i]);
+ }
+ }
+
+ close(to_lockers[0]);
+ for (i = 0; i < nproc; ++i) {
+ if (TFR(write(to_lockers[1], &c, 1)) != 1) {
+ perror("write child");
+ return 1;
+ }
}
+ close(to_lockers[1]);
for (i = 0; i < nproc; ++i) {
int status;