[Mono-list] How does Monitor.Enter work?

Vincent Povirk madewokherd at gmail.com
Wed Jul 20 23:41:04 EDT 2011


mono/metadata/icall-def.h contains references to the implementations
of internal calls. Apparently, that method is mono_monitor_enter,
implemented in monitor.c.

On Wed, Jul 20, 2011 at 9:54 PM, imays <imays at naver.com> wrote:
> I got a question how Monitor.Enter works. I investigated .net framework
> source code, and it shows this only:
>
>        [System.Security.SecurityCritical]  // auto-generated
>        [ResourceExposure(ResourceScope.None)]
>        [MethodImplAttribute(MethodImplOptions.InternalCall)]
>        private static extern void ReliableEnter(Object obj, ref bool
> lockTaken);
>
> I guess Monitor.Enter implementation is platform dependent, so I browsed
> Mono source code and I gave up :(
>
> Yes, a critical section assigned for each System.Object instance may solve,
> but, I don't think the actual Monitor.Lock is written like this, because
> creating a critical section for each System.Object will cost unlimitedly.
> (Win32 does not allow billions of critical section objects in a process!)
>
> Does anybody know how Monitor.Lock works? Please reply. Thanks in advance.
>
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/How-does-Monitor-Enter-work-tp3682685p3682685.html
> Sent from the Mono - General mailing list archive at Nabble.com.
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>


More information about the Mono-list mailing list