[webkit-dev] Atomic read/write operations and thread safety
steveblock at google.com
Wed Dec 15 04:28:44 PST 2010
I have a question about whether WebCore code makes assumptions about
the atomicity of certain read/write operations.
The particular instance I'm interested in is IconDatabase, where
m_threadTerminationRequested is written to from the main thread (in
close() for example) and read from the DB thread (in
syncThreadMainLoop()) without any locking. It looks like the code is
written such that there's no particular synchronization requirement in
terms of the order in which the value is set and read. But there's a
risk of a garbled read in the case of a simultaneous read and write
from the two threads.
I assume that the lack of locking is an intentional decision, based on
the fact that on all relevant architectures, a boolean read/write is
Is this a general WebCore policy? It would be great if somebody could
confirm this, or point out why I'm wrong.
Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902
More information about the webkit-dev