MutableCallSite syncAll memory effects

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

MutableCallSite syncAll memory effects

thurstonn
Reading the MutableCallSite#syncAll javadoc, there seems to be an inconsistency, viz.

this passage (call it P):
"The overall effect is to force all future readers of each call site's target to accept the most recently stored value"

doesn't quite gibe with:
"Consider an arbitrary thread T (other than the current thread). If T executes a synchronization action A after the volatile write to V (in the global synchronization order), it is therefore required to see ... the current target of [the MutableCallSite]"

But what if T never performs any subsequent synchronization action (i.e. A)?  There's nothing to suggest that reading the callsite's #target or invoking the callsite (which implies the former) constitutes a synchronization action.

Yet passage P imposes no such condition on T (a future reader); given cache coherency, this probably isn't a real-world issue, but there appears to be an inconsistency, unless I'm missing something
Reply | Threaded
Open this post in threaded view
|

Re: MutableCallSite syncAll memory effects

Remi Forax
The effect of setTarget/syncAll is described in term of volatile read/volatile write.
"In terms of the Java Memory Model, this operation performs a synchronization action which is comparable in effect to the writing of a volatile variable by the current thread, and an eventual volatile read by every other thread that may access one of the affected call sites."

The volatile read is not something that really occurs, a thread that read the target, using getTarget(), of a MutableCallSite acts *as if* the target was read by a volatile read if syncAll was called before.

cheers,
Rémi

----- Mail original -----

> De: "thurstonn" <[hidden email]>
> À: [hidden email]
> Envoyé: Mercredi 18 Novembre 2015 00:07:52
> Objet: [concurrency-interest] MutableCallSite syncAll memory effects
>
> Reading the  MutableCallSite#syncAll javadoc
> <http://docs.oracle.com/javase/8/docs/api/java/lang/invoke/MutableCallSite.html#syncAll-java.lang.invoke.MutableCallSite:A->
> , there seems to be an inconsistency, viz.
>
> this passage (call it P):
> "The overall effect is to force all future readers of each call site's
> target to accept the most recently stored value"
>
> doesn't quite gibe with:
> "Consider an arbitrary thread T (other than the current thread). *If T
> executes a synchronization action A* after the volatile write to V (in the
> global synchronization order), it is therefore required to see ... the
> current target of [the MutableCallSite]"
>
> But what if T never performs any subsequent synchronization action (i.e. A)?
> There's nothing to suggest that reading the callsite's #target or invoking
> the callsite (which implies the former) constitutes a synchronization
> action.
>
> Yet passage P imposes no such condition on T (a future reader); given cache
> coherency, this probably isn't a real-world issue, but there appears to be
> an inconsistency, unless I'm missing something
>
>
>
> --
> View this message in context:
> http://jsr166-concurrency.10961.n7.nabble.com/MutableCallSite-syncAll-memory-effects-tp12882.html
> Sent from the JSR166 Concurrency mailing list archive at Nabble.com.
> _______________________________________________
> Concurrency-interest mailing list
> [hidden email]
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest