[Live-devel] use of volatile in doEventLoop for interthread synchronization

gback gback at cs.vt.edu
Thu Aug 1 09:49:04 PDT 2024


Hi,

the current Live555 uses `volatile` for interthread synchronization in 
doEventLoop.

As per C++ specification, volatile cannot be used for this purpose and 
in fact introduces
undefined behavior. (*)  Although we can argue about what practical 
effect this has I
believe that just following the specification is the safer route, 
particularly on SMP.

I believe that Ross is aware that you can't use volatile to synchronize 
between different threads (**),
but as of today the wrong use of volatile is still in the code base.

Although changing the signature of doEventLoop might break existing 
applications, is this something
to consider?

  - Godmar


(*) https://en.cppreference.com/w/cpp/language/cv
(**) http://lists.live555.com/pipermail/live-devel/2023-June/022315.html


More information about the live-devel mailing list