vendredi 20 octobre 2023

std::atomic

Can a std::atomic<T> that is verified to be lock free or a std::atomic_flag safely be used in an Interrupt Service Handler (ISR) to pass a message/flag/indicator from Interrupt Context to another thread or process?

I'm defining std::atomic<T> as lock free if std::atomic<T>::is_always_lock_free is true or if std::atomic<T>::is_lock_free is checked for each instance of std::atomic<T>.

The standard does not mention any usage of interrupts in the atomic documentation. This other answer compares volatile for interrupts and std::atomic for inter-thread communication.

Aucun commentaire:

Enregistrer un commentaire