My problem: A,B - semaphores.
Process is loop:
- waits for A >= 1, decrements A
- does some computation
- increments B.
- back to 1.
Goal: After process terminates i need decrements of A be equal to increments of B.
So i figure out i will add flag SEM_UNDO in 1. but it undos every DEcrement ever made to A by that process. How to revoke / undo SEM_UNDO from 1. when process reaches 4.?
ok, i was enlightened when thinking about problem as "undoing" SEM_UNDO rather then "revoking" it.
after calling semop() with operation +x with SEM_UNDO, you can later undo that SEM_UNDO by calling semop() again with two operations: