Path: csiph.com!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail From: cross@spitfire.i.gajendra.net (Dan Cross) Newsgroups: comp.lang.c++ Subject: Re: std::atomic work as volatile, or not, I think not... Date: Mon, 11 May 2026 11:53:10 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <10tsfv6$3fe$1@reader1.panix.com> References: <10trn7n$s8gl$1@dont-email.me> <10trspj$t8pr$2@dont-email.me> <10ts3vt$3v1g3$1@dont-email.me> <10ts5ur$updt$2@dont-email.me> Injection-Date: Mon, 11 May 2026 11:53:10 -0000 (UTC) Injection-Info: reader1.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="3566"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross) Xref: csiph.com comp.lang.c++:123825 In article <10ts5ur$updt$2@dont-email.me>, David Brown wrote: >On 11/05/2026 10:28, boltar@caprica.universe wrote: >> On Mon, 11 May 2026 08:25:55 +0200 >> David Brown gabbled: >>> On 11/05/2026 06:51, Chris M. Thomasson wrote: >>>> Well, damn. It seems that std::atomic might not be sufficient, and >>>> volatile needs to be used. >>>> >>> >>> I very much hope to be corrected if someone thinks my reasoning below >>> is incorrect - I am not an expert here by any means. >> >> Whats the point of std::atomic anyway? Just how often does a thread >> critical >> section just require the test and set of a single value? And if you do >> want to do that posix semaphores have been a thing since the early 90s >> and SysV ones since at least the 80s if not earlier. >> > >Atomics are for shared information /without/ needing semaphores, >critical sections or other more expensive operations. Read up about >non-blocking or lock-free algorithms. And also for implementing such things. - Dan C.