[concurrency-interest] a question about concurrent safe access

Stefan Skoglund stefan.skoglund at it-huset.se
Mon Sep 19 07:36:36 EDT 2005


Theoretically, I guess you could get a dirty reference if you used a 
volatile reference. Consider the two treads X and Y. And consider 
volatile reference R pointing to A, seen by both threads. If X creates 
object B and lets R point to B, then Y would see reference R point to 
where B should reside. But since no memory synchronization is guarantied 
to have occurred. except the volatile reference. it would be possible 
that Y sees a dirty reference.

However as I understand, the current implementation of volatile reads 
and writes, does perform full blown memory synchronization between two 
threads, exchanging information through a volatile reference. So the 
dirty reference would never appear. I'm not sure one should rely the 
fullblown memory synchronization though.

I guess one of the experts could verify this.

yours
/Stefan


Yechiel Feffer wrote:

> Hi all
> say I have a pointer ( reference) to an object ( A). This reference is 
> changed to point at object B. I have threads that concurrently are 
> using that reference to get the object it points at. I dont want to 
> synchronize the usage of the reference. Is it safe to do so, i.e. if I 
> dont use a lock and I dont declare the reference volatile will I 
> always get object A or B or do I have a risk of getting "dirty" 
> inconsistent pointer , i.e. is assigning a pointer always atomic  ?
>
> Regrds,
> Yechiel  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Concurrency-interest mailing list
>Concurrency-interest at altair.cs.oswego.edu
>http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>  
>




More information about the Concurrency-interest mailing list