2009-05-12 Kornél Pál <kornelpal@gmail.com>
authorKornél Pál <kornelpal@gmail.com>
Tue, 12 May 2009 09:07:56 +0000 (09:07 -0000)
committerKornél Pál <kornelpal@gmail.com>
Tue, 12 May 2009 09:07:56 +0000 (09:07 -0000)
* gc.c (mono_gc_init): Set gc_thread on creation. This avoids the
prevous wait that resulted in a deadlock on Windows when initializing
the runtime form DllMain. Also results in improved startup time.
(finalizer_thread): Get rid of thread_started_event.
* threads.c, threads-types.h (mono_thread_create_internal): Return the
resulting MonoThread.

Contributed under MIT/X11 license.

Also fixed ChangeLog encoding.

svn path=/trunk/mono/; revision=133959

mono/metadata/ChangeLog
mono/metadata/gc.c
mono/metadata/threads-types.h
mono/metadata/threads.c

index 84420795efdd499674dd2fa021359aa2874112ef..8ed5d90295dfe976cfb2d6a7648db231f406ecc9 100644 (file)
@@ -1,3 +1,14 @@
+2009-05-12  Kornél Pál  <kornelpal@gmail.com>
+
+       * gc.c (mono_gc_init): Set gc_thread on creation. This avoids the
+       prevous wait that resulted in a deadlock on Windows when initializing
+       the runtime form DllMain. Also results in improved startup time.
+       (finalizer_thread): Get rid of thread_started_event.
+       * threads.c, threads-types.h (mono_thread_create_internal): Return the
+       resulting MonoThread.
+
+       Contributed under MIT/X11 license.
+
 2009-05-11 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * metadata-verify.c: Verify the implmap table.
@@ -3002,7 +3013,7 @@ Thu Dec 18 16:35:22 CET 2008 Paolo Molaro <lupus@ximian.com>
 
        Fixes #448560.
 
-2008-11-29  Korn�l P�l  <kornelpal@gmail.com>
+2008-11-29  Kornél Pál  <kornelpal@gmail.com>
 
        * coree.c (MonoFixupExe): Use sizeof(IMAGE_BASE_RELOCATION) instead of
        IMAGE_SIZEOF_BASE_RELOCATION as newer Vista SDKs no longer define the latter.
@@ -3723,7 +3734,7 @@ Mon Oct 6 16:10:02 CEST 2008 Paolo Molaro <lupus@ximian.com>
        for the no-gc case.
        * attach.c (mono_attach_init): Remove the #ifdef.
 
-2008-10-04  Andreas Frber  <andreas.faerber@web.de>
+2008-10-04  Andreas Färber  <andreas.faerber@web.de>
 
        * attach.c (mono_attach_init): Don't use
        mono_gc_add_finalizer_thread_callback when compiling without GC.
@@ -3903,7 +3914,7 @@ Mon Sep 22 17:29:54 CEST 2008 Paolo Molaro <lupus@ximian.com>
        (mono_image_get_generic_field_token): Call add_custom_modifiers ().
        (fieldbuilder_to_mono_class_field): Ditto. Fixes #424663.
 
-2008-09-19  Korn�l P�l  <kornelpal@gmail.com>
+2008-09-19  Kornél Pál  <kornelpal@gmail.com>
 
        * coree.c (_CorValidateImage): Some 64-bit IL only images have entry point
        calling _CorDllMain imported from mscoree.dll. Set entry point RVA to 0 for
@@ -4356,7 +4367,7 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
        (ves_icall_System_Diagnostics_Process_ProcessHandle_duplicate):
        New internal calls to duplicate and close a process handle.
 
-2008-07-27  Andreas Frber  <andreas.faerber@web.de>
+2008-07-27  Andreas Färber  <andreas.faerber@web.de>
 
        * object.c (CHECK_ADD_OVERFLOW_UN): Add missing bracket. Fixes #412499.
 
@@ -4483,7 +4494,7 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
        * class-internals.h: New exception type MONO_EXCEPTION_OBJECT_SUPPLIED
        for the case where the exception object is supplied.
 
-2008-07-16  Korn�l P�l  <kornelpal@gmail.com>
+2008-07-16  Kornél Pál  <kornelpal@gmail.com>
 
        * coree.h: Define __ImageBase as _image_base__ on cygwin that fixes build with
        old ld versions.
@@ -4654,7 +4665,7 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
 
        * domain.c: Initialize+cleanup jit_code_hash_lock.
        
-2008-06-30  Korn�l P�l  <kornelpal@gmail.com>
+2008-06-30  Kornél Pál  <kornelpal@gmail.com>
 
        * coree.c (mono_load_coree): Set coree_module_handle global variable only
        after initialization.
@@ -4663,7 +4674,7 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
 
        Contributed under MIT/X11 license.
 
-2008-06-30  Korn�l P�l  <kornelpal@gmail.com>
+2008-06-30  Kornél Pál  <kornelpal@gmail.com>
 
        * coree.c (_CorValidateImage): Retain IMAGE_DIRECTORY_ENTRY_SECURITY
        because that is platform independent. Check NumberOfRvaAndSizes in PE32
@@ -4721,7 +4732,7 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
 
        * object.c (mono_value_box): Fix boxing of nullables.
 
-2008-06-26  Korn�l P�l  <kornelpal@gmail.com>
+2008-06-26  Kornél Pál  <kornelpal@gmail.com>
 
        * assembly.c (mono_set_rootdir): Use __ImageBase instead of
        mono_module_handle that is defined by the linker; no initialization required.
@@ -4840,7 +4851,7 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
        * icall-def.h: Implement Socket generic Send() and Receive()
        methods.  Fixes bug 395168.
 
-2008-06-19  Korn�l P�l  <kornelpal@gmail.com>
+2008-06-19  Kornél Pál  <kornelpal@gmail.com>
 
        * icall-def.h, icall.c: Add ves_icall_System_Reflection_Module_GetHINSTANCE.
 
@@ -5314,7 +5325,7 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
        * appdomain.c (set_domain_search_path): Acquire the domain lock since we
        modify domain state.
 
-2008-06-05  Andreas Frber  <andreas.faerber@web.de>
+2008-06-05  Andreas Färber  <andreas.faerber@web.de>
 
        * boehm-gc.c: Add DTrace probes gc-{begin,end}.
        * Makefile.am (pedump_LDADD): Post-process object files and
@@ -5850,14 +5861,14 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
        * reflection.c (mono_image_create_token): Add a 'register_token' argument, and use
        it to avoid registering tokens during metadata generation. Fixes #390023.
 
-2008-05-14  Korn�l P�l  <kornelpal@gmail.com>
+2008-05-14  Kornél Pál  <kornelpal@gmail.com>
 
        * coree.c: Rename dwOldProtect to OldProtect that makes naming convention
        consistent.
 
        Contributed under MIT/X11 license.
 
-2008-05-14  Korn�l P�l  <kornelpal@gmail.com>
+2008-05-14  Kornél Pál  <kornelpal@gmail.com>
 
        * domain.c (mono_init_internal): Enable LoadLibrary support. Load EXE image
        even when get_runtimes_from_exe didn't load it that allows mono_fixup_exe_image
@@ -6013,13 +6024,13 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
        (MONO_SYMBOL_FILE_COMPATIBILITY_VERSION): Removed; dropped support
        for old pre-terrania symbol files.
 
-2008-05-05  Andreas Frber  <andreas.faerber@web.de>
+2008-05-05  Andreas Färber  <andreas.faerber@web.de>
 
        * mono-config.c: Add ppc64 architecture.
 
        Code is contributed under MIT/X11 license.
 
-2008-05-05  Andreas Frber  <andreas.faerber@web.de>
+2008-05-05  Andreas Färber  <andreas.faerber@web.de>
 
        * object.c (mono_create_ftnptr, mono_get_addr_from_ftnptr):
          PPC64 uses function descriptors as well.
@@ -6102,7 +6113,7 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
        * verify.c (mono_method_verify): Check the bounds of
        all access of the code array.
 
-2008-04-29  Korn�l P�l  <kornelpal@gmail.com>
+2008-04-29  Kornél Pál  <kornelpal@gmail.com>
 
        * appdomain.c: Use HAVE_SYS_UTIME_H that fixes MSVC build.
 
@@ -6111,7 +6122,7 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
        * image.c (mono_image_strong_name_position): Fix return value when the rva is
        not valid.
 
-2008-04-28  Korn�l P�l  <kornelpal@gmail.com>
+2008-04-28  Kornél Pál  <kornelpal@gmail.com>
 
        * loader.c (mono_get_method_from_token, mono_method_signature): Add
        support for METHOD_IMPL_ATTRIBUTE_NATIVE.
@@ -6477,7 +6488,7 @@ Fri Aug 1 16:07:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
 
        * verify.c: Implemented readonly prefix and verify controled mutability pointers.
 
-2008-03-20  Korn�l P�l  <kornelpal@gmail.com>
+2008-03-20  Kornél Pál  <kornelpal@gmail.com>
 
        * file-io.c, filewatcher.c, threadpool.c, threads.c: Removed Windows
        version macros.
@@ -8330,7 +8341,7 @@ Thu Nov 8 15:31:21 CET 2007 Paolo Molaro <lupus@ximian.com>
        * socket-io.c: Apple requires sin(6)_len to be set for getnameinfo
        to succeed
 
-2007-11-05  Korn�l P�l  <kornelpal@gmail.com>
+2007-11-05  Kornél Pál  <kornelpal@gmail.com>
 
        * process.c: Added run-time GetProcessId API detection for Windows.
 
@@ -12641,7 +12652,7 @@ Fri Jul 28 19:04:34 CEST 2006 Paolo Molaro <lupus@ximian.com>
        * threads.c (start_wrapper): Do the thread cleanup while we still
        hold a reference to its object.  Fixes bug 78123.
 
-2006-07-18  Korn�l P�l  <kornelpal@gmail.com>
+2006-07-18  Kornél Pál  <kornelpal@gmail.com>
 
        * class-internals.h: Added MONO_WRAPPER_MANAGED_TO_MANAGED wrapper type.
        * debug-helpers.c: Map MONO_WRAPPER_MANAGED_TO_MANAGED to
@@ -16482,7 +16493,7 @@ Wed Jun 8 19:26:38 CEST 2005 Paolo Molaro <lupus@ximian.com>
 
        * threads.c: avoid segfault when an unstarted thread is aborted.
 
-2005-06-05  Korn�l P�l <kornelpal@hotmail.com>
+2005-06-05  Kornél Pál <kornelpal@hotmail.com>
 
        * icall.c: Added ves_icall_Mono_Runtime_GetDisplayName:
        Returns the name and version of the runtime for reporting.
index bbd47f76f29aa44de42789f1bd89c669254ed65c..26fc60adb091555f60c41322fb6d02b2921ca6c7 100644 (file)
@@ -73,7 +73,6 @@ static void mono_gchandle_set_target (guint32 gchandle, MonoObject *obj);
 #ifndef HAVE_NULL_GC
 static HANDLE pending_done_event;
 static HANDLE shutdown_event;
-static HANDLE thread_started_event;
 #endif
 
 static void
@@ -992,10 +991,6 @@ finalize_domain_objects (DomainFinalizationReq *req)
 static guint32
 finalizer_thread (gpointer unused)
 {
-       gc_thread = mono_thread_current ();
-
-       SetEvent (thread_started_event);
-
        while (!finished) {
                /* Wait to be notified that there's at least one
                 * finaliser to run
@@ -1057,26 +1052,14 @@ mono_gc_init (void)
        finalizer_event = CreateEvent (NULL, FALSE, FALSE, NULL);
        pending_done_event = CreateEvent (NULL, TRUE, FALSE, NULL);
        shutdown_event = CreateEvent (NULL, TRUE, FALSE, NULL);
-       thread_started_event = CreateEvent (NULL, TRUE, FALSE, NULL);
-       if (finalizer_event == NULL || pending_done_event == NULL || shutdown_event == NULL || thread_started_event == NULL) {
+       if (finalizer_event == NULL || pending_done_event == NULL || shutdown_event == NULL) {
                g_assert_not_reached ();
        }
 #if USE_POSIX_SEM
        sem_init (&finalizer_sem, 0, 0);
 #endif
 
-       mono_thread_create (mono_domain_get (), finalizer_thread, NULL);
-
-       /*
-        * Wait until the finalizer thread sets gc_thread since its value is needed
-        * by mono_thread_attach ()
-        *
-        * FIXME: Eliminate this as to avoid some deadlocks on windows. 
-        * Waiting for a new thread should result in a deadlock when the runtime is
-        * initialized from _CorDllMain that is called while the OS loader lock is
-        * held by LoadLibrary.
-        */
-       WaitForSingleObjectEx (thread_started_event, INFINITE, FALSE);
+       gc_thread = mono_thread_create_internal (mono_domain_get (), finalizer_thread, NULL, FALSE);
 }
 
 void
index 92093ed264c972b87d946f20e651d6fe12626f13..1f98902215bb2e0fe9f62f5e1659619489a46417 100644 (file)
@@ -53,7 +53,7 @@ gpointer mono_create_thread (WapiSecurityAttributes *security,
                                                         guint32 stacksize, WapiThreadStart start,
                                                         gpointer param, guint32 create, gsize *tid) MONO_INTERNAL;
 
-void mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, gboolean threadpool_thread) MONO_INTERNAL;
+MonoThread* mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, gboolean threadpool_thread) MONO_INTERNAL;
 
 HANDLE ves_icall_System_Threading_Thread_Thread_internal(MonoThread *this_obj, MonoObject *start) MONO_INTERNAL;
 void ves_icall_System_Threading_Thread_Thread_init(MonoThread *this_obj) MONO_INTERNAL;
index c299b7f9a8c0d77be1bb47eccb368848bb4d9e0c..f8d827983d7e41f6d145a2b6ef5e5bfbd0b79040 100644 (file)
@@ -709,7 +709,7 @@ gpointer mono_create_thread (WapiSecurityAttributes *security,
        return res;
 }
 
-void mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, gboolean threadpool_thread)
+MonoThread* mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, gboolean threadpool_thread)
 {
        MonoThread *thread;
        HANDLE thread_handle;
@@ -734,7 +734,7 @@ void mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer ar
        mono_threads_lock ();
        if (shutting_down) {
                mono_threads_unlock ();
-               return;
+               return NULL;
        }
        if (threads_starting_up == NULL) {
                MONO_GC_REGISTER_ROOT (threads_starting_up);
@@ -757,7 +757,7 @@ void mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer ar
                mono_threads_unlock ();
                g_free (start_info);
                mono_raise_exception (mono_get_exception_execution_engine ("Couldn't create thread"));
-               return;
+               return NULL;
        }
 
        thread->handle=thread_handle;
@@ -774,6 +774,8 @@ void mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer ar
 
        if (handle_store (thread))
                ResumeThread (thread_handle);
+
+       return thread;
 }
 
 void