[vlc-devel] [PATCH 1/6] os2: implement vlc_once()
Rémi Denis-Courmont
remi at remlab.net
Sat Apr 7 19:14:49 CEST 2018
Le lauantaina 7. huhtikuuta 2018, 19.06.07 EEST KO Myung-Hun a écrit :
> > At least a compiler barrier *in practice*, but not in theory (so this is
> > not guaranteed). And the CPU might also reorder.
>
> Reordering of both a compiler and a CPU should guarantee that the result
> of reordering is the same as the one of the sequential in a single thread.
Sure, all the provided patches work fine in the single thread case on any
platform.
But the whole point of vlc_once() is deal with multiple threads and concurrent
calls.
> And compiler cannot see the internal of cb().
With LTO and IPA combined, a compiler can propagate vlc_CPU_init as the cb
value into vlc_once() from vlc_CPU().
Not that it matters much. The problem is not a lack of release fence.
Unlocking the mutex provides a release fence. The problem is the lack fo
acquire fence before reading the flag.
--
雷米‧德尼-库尔蒙
https://www.remlab.net/
More information about the vlc-devel
mailing list