Boost logo

Boost :

From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2020-05-20 12:55:29


On 20/05/2020 13:18, Andrey Semashev via Boost wrote:
> On 2020-05-19 15:55, Niall Douglas via Boost wrote:
>>
>> Coming back to shared memory mutexes etc, me personally if I want a
>> mutex that is shared across processes and is resilient to sudden process
>> death, I just lock a shared file in /tmp using flock().
>
> Do you have any performance numbers of flock vs. e.g. futex? I would
> expect the former to be considerably slower.

It depends hugely on platform. Linux might do 100k ops/sec. FreeBSD
might do 600k ops/sec. Windows might do 20k ops/sec (a Win32 event
object or semaphore is much faster).

All are very considerably slower than a cmpxchg into shared memory.

The only way that I know of to get both the speed of an atomic, and
robustness, is to launch a dedicated monitor process which can break
hanged locks if the owning process unexpectedly dies. LLFIO has the
world's simplest child process support for exactly this purpose, as
llfio::process_handle.

Niall


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