News for hackers. Stuff that matters.
Re:Website hosted on a 24 year old Linux server by wahern on Thursday April 06, 2023 @08:37PM (#35476569)
You don't need mlock for the interprocess atomicity. There may be a race if you intend the file to be persistent; write-back to disk wouldn't necessarily be atomic. But mlock doesn't solve that problem, it just might make it slightly less likely to result in corruption if it means less flushing. To truly solve it you need a proper synchronization mechanism, e.g. a mutex to quiet all writers, then a blocking sync. OTOH, write-back for a single native integer may actually be atomic, assuming it doesn't cross a cache line, so in practice a simple mmap may be sufficient. (I emphasize may, though. I'm not that familiar with the inner mechanics of DMA, block device buffering, etc.)

You don't need assembly, either, as standard atomic built-ins in C, C++, etc, will work just fine, as will FFI to such built-ins.

There are no comments on this comment yet.