fprintf(stdout, "wait completed on %d: count=%" PRIu64 "\n",
fd, cntr);
+ fflush(stdout);
}
static void xsem_post(int fd, int count)
* (also xsem_wait above)
*/
fprintf(stdout, "posting 1 on %d\n", fd1);
+ fflush(stdout);
xsem_post(fd1, 1);
fprintf(stdout, "waiting on %d\n", fd2);
+ fflush(stdout);
xsem_wait(fd2);
fprintf(stdout, "posting 1 on %d\n", fd1);
+ fflush(stdout);
xsem_post(fd1, 1);
fprintf(stdout, "waiting on %d\n", fd2);
+ fflush(stdout);
xsem_wait(fd2);
fprintf(stdout, "posting 5 on %d\n", fd1);
+ fflush(stdout);
xsem_post(fd1, 5);
fprintf(stdout, "waiting 5 times on %d\n", fd2);
+ fflush(stdout);
xsem_wait(fd2);
xsem_wait(fd2);
xsem_wait(fd2);
sem_player(fd1, fd2);
exit(0);
}
+ sleep(1);
if ((cpid_waiter = fork()) == 0) {
sem_player(fd2, fd1);
exit(0);
posting 1 on 3
waiting on 4
+posting 1 on 4
wait completed on 4: count=1
+waiting on 3
posting 1 on 3
waiting on 4
-wait completed on 4: count=1
-posting 5 on 3
-waiting 5 times on 4
-wait completed on 4: count=1
-wait completed on 4: count=1
-wait completed on 4: count=1
-wait completed on 4: count=1
-wait completed on 4: count=1
-posting 1 on 4
-waiting on 3
wait completed on 3: count=1
posting 1 on 4
+wait completed on 4: count=1
waiting on 3
wait completed on 3: count=1
+posting 5 on 3
posting 5 on 4
+waiting 5 times on 4
+wait completed on 4: count=1
waiting 5 times on 3
+wait completed on 4: count=1
wait completed on 3: count=1
+wait completed on 4: count=1
wait completed on 3: count=1
+wait completed on 4: count=1
wait completed on 3: count=1
+wait completed on 4: count=1
wait completed on 3: count=1
wait completed on 3: count=1