[Bug libstdc++/126235] std::atomic<std::shared_ptr<T>> can stall under SCHED_FIFO on a single CPU

"redi at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126235

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Wolfgang Hoffmann from comment #2)
> To my understanding, the load/store operations should be atomic in the sense
> that concurrent action is serialized in arbitrary order, but done
> atomically.

I don't know what you mean by "atomically", but
std::atomic<std::shared_ptr<T>>::is_always_lock_free is false, which means that
operations on that type are *not* actually atomic, they are protected by a
lock.

The std::atomic_load and std::atomic_store functions are also protected by a
lock but they use a POSIX mutex to serialize and so maybe the difference is
that libc makes the low-prio thread inherit the priority of the high-prio
thread when contended on the same mutex.

The locking done by std::atomic<std::shared_ptr<T>> is not based on POSIX
mutexes, just a spinlock on a single bit. There's no priority inheritance.

So I think Drea is correct in comment 1.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.