Date: Wed, 10 Jun 2026 08:59:07 -0700
On Wednesday, 10 June 2026 08:41:42 Pacific Daylight Time Thiago Macieira via
Std-Discussion wrote:
> extern std::atomic<int64_t> steady_clock_value;
> int64_t timestamp()
> { return steady_clock_value.load(std::memory_order_relaxed); }
>
> And there's another thread somewhere that periodically executes:
>
> steady_clock_value.fetch_add(1, std::memory_order_relaxed);
I used relaxed in the code above, but inspecting the Linux source code, I see
it uses smp_rmb to read the clock and smp_wmb to write to it, so I think this
would match an acquire/release pair. See the read helpers in
https://codebrowser.dev/linux/linux/include/vdso/helpers.h.html
I don't know if this is required by the Standard. I also don't know if all
platforms have this behaviour either.
Std-Discussion wrote:
> extern std::atomic<int64_t> steady_clock_value;
> int64_t timestamp()
> { return steady_clock_value.load(std::memory_order_relaxed); }
>
> And there's another thread somewhere that periodically executes:
>
> steady_clock_value.fetch_add(1, std::memory_order_relaxed);
I used relaxed in the code above, but inspecting the Linux source code, I see
it uses smp_rmb to read the clock and smp_wmb to write to it, so I think this
would match an acquire/release pair. See the read helpers in
https://codebrowser.dev/linux/linux/include/vdso/helpers.h.html
I don't know if this is required by the Standard. I also don't know if all
platforms have this behaviour either.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2026-06-10 15:59:16
