fix off-by-one error in sem_(timed)wait (using old sem value instead of new)