[Mono-list] How to implement the monitor synchronization?

Miguel de Icaza miguel@ximian.com
13 Nov 2001 22:50:13 -0500


> > That's correct.  Although a clever engine could inline
> > the calls to those methods within the JIT, and essentially
> > "bring up" the implementation into the caller.  The final
> > effect would be the same as the monitorenter/exit opcodes.
> 
> But wait a second! What happens when control is transfered out of the
> basic block. Of course the compiler inserts call to monitor exit just
> before method return, but what about when exceptions are thrown. The CLI
> needs to release monitors when unwinding?

The compiler generates code for the `lock' statement that includes a
try/finally block and takes care of this.

Miguel.