Hi,

Am 15.12.2010 18:43, schrieb Brady Eidson:
On Dec 15, 2010, at 8:47 AM, Brady Eidson wrote:
On Dec 15, 2010, at 4:28 AM, Steve Block wrote:
I wouldn't be surprised if there were other examples of an unprotected thread 
shared boolean in either WebCore or any platform's WebKit.

In hindsight I realize my response involved assumptions about this code that 
were known to me but not to the general audience, so I'll followup more 
thoroughly.

The boolean in question isn't both checked and set at the same time - it's not 
an acquired resource.  One thread sets it, the other checks it.  My belief is 
that this is safe for booleans, but I would love to hear where I'm wrong.

I have seen this particular technique quite often before. The only thing one needs to watch out for is to declare such a boolean volatile (which I believe this code does, if memory serves). Otherwise the thread which polls the condition may read from a cached location and miss the change. Worst that can happen on a hypothecial architecture where writing a byte is not atomic is that the changed condition takes affect one loop cycle later.

Best regards,
-Stephan
_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to