[concurrency-interest] Roach motels

Jeremy Manson jmanson at cs.purdue.edu
Thu Nov 17 00:00:58 EST 2005


Steve Kautz wrote:
> Jeremy, thanks for that quick reply.

No problem.  In answer to your question below, the answer is "a)", the 
system has to ensure that it isn't introducing deadlock.  If it can't do 
so, then it can't perform the transformation.  If it can't analyze 
unknown method calls, then it can't perform the transformation.

[I thought I sent this hours ago!]

					Jeremy

> 
> 
>>OTOH, a system cannot, in general, take this:
>>
>>   synchronized (this) {
>>     // stuff
>>   }
>>   synchronized (that) {
>>     // more stuff
>>   }
>>   synchronized (this) {
>>     // even more stuff
>>   }
>>
>>and change it to this:
>>
>>synchronized (this) {
>>   // stuff
>>
>>   synchronized (that) {
>>     // more stuff
>>   }
>>
>>   // even more stuff
>>}
>>
>>because this can introduce deadlock, which may introduce errors in your
>>program.
> 
> 
> 
> Right. So I think the interesting question is then, in which direction does
> the burden of proof go?   For example, if instead of literally having
> synchronized(that) we again have something like:
> 
>   synchronized (this) {
>      // stuff
>    }
> 
>    otherObject.bar();
> 
>    }
>    synchronized (this) {
>      // even more stuff
>    }
> 
> how far is the system obligated to look before concluding that bar() will,
> or won't, enter a block of the form synchronized(that)?
> 
> In particular, in the OSGi example mentioned earlier, method bar()
> ultimately invokes callback methods for a list of listeners, some of which
> may be synchronized, and which are added/removed dynamically at runtime.  So
> no amount of static analysis will show whether or not a call to bar() will
> end up invoking "synchronized(that)".   Does the system a) assume that a
> method call may end up in synchronized code unless it can prove otherwise,
> or does it b) assume it's ok to coalesce the blocks unless it can show that
> the call includes something like "synchronized(that)"?
> 
> -- Steve K
> 
> _______________________________________________
> 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