21 Sep
2013
21 Sep
'13
9:07 a.m.
i was also under the impression that wait/post should be acquire/release, both for semaphores and for events. get_value() may need some special care, but i'm not planning to add this to the sync::semaphore interface, because it is not widely supported: neither mach nor dispatch semaphores provide an API for accessing the semaphore count.
Ok, nice. In any case, if sem_getvalue or similar should synchronize with boty post() and wait() and read the most recent value, if the semaphore is emulated with an atomic emulation on an integer I think a Read-Modify-Write operation with memory_order_acq_rel be the answer (something like fetch_add with argument 0?) Reading the count while the mutex is hold shouldn't also work? Best, Ion