I know it is undefined behaviour. Hence the possibility of data race or crash. One can use atomicbool to avoid such possibilities. What I am interested to know about the crash safety.
AFAIU, crash may happen when one thread reads the partially written or torn value by another thread. On the other hand the size of the bool is implementation defined but it hardly make sense to have that greater than the size of pointer in a data model .
is it safe to assume that the memory block of bool will either be updated or not? Therefore, other thread cannot read the torn value hence it is crash safe to read/write global bool from different threads ?
Aucun commentaire:
Enregistrer un commentaire