2009/11/11 <joerg-cyril.hoe...@t-systems.com>: > Hi, > > AJ wrote in > http://www.winehq.org/pipermail/wine-devel/2009-November/079575.html >>If there is proper synchronization you don't need >>volatile, and if there isn't volatile won't magically fix it. > > However, mcimidi has in its code since pre 1999: > :/* it seems that in case of multi-threading, gcc is optimizing just a little > bit > : * too much. Tell gcc not to optimize status value using volatile. > : */ > :while (((volatile WINE_MCIMIDI*)wmm)->dwStatus == MCI_MODE_PAUSE); > > The comment is right. Any C compiler is allowed to optimize this into > an endless loop without volatile. But I'd rather see the following: > :volatile dwStatus = NOT_READY; /* one central declaration */ > :... > :while (wmm->dwStatus == PAUSE) ; /* what, busy wait!?! */ > > So what's the use of volatile? When is it appropriate in Wine?
I haven't looked in detail at the context of your patch, but this looks appropriate to it: http://lkml.indiana.edu/hypermail/linux/kernel/0607.0/1566.html Particularly the part about volatile storage vs. access. -- Rob Shearman