Boost logo

Boost :

Subject: Re: [boost] [thread] semaphore
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2013-09-21 05:07:55


> 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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk