delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2001/04/16/09:05:05

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-developers-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com
Message-ID: <035e01c0c675$c2c11180$0200a8c0@voyager>
From: "Trevor Forbes" <trevorforbes AT ozemail DOT com DOT au>
To: "Cygwin-developers" <cygwin-developers AT cygwin DOT com>
References: <037701c0c3ab$9049bf30$0200a8c0 AT lifelesswks> <20010413221222 DOT C5606 AT dothill DOT com> <006001c0c4af$179b79c0$0200a8c0 AT lifelesswks> <20010414223139 DOT A906 AT redhat DOT com> <001701c0c557$02a861b0$0200a8c0 AT lifelesswks> <20010415090600 DOT A8359 AT redhat DOT com> <001301c0c5af$9cb7e520$0200a8c0 AT lifelesswks> <20010415153317 DOT C9015 AT redhat DOT com> <013b01c0c613$53cdac00$0200a8c0 AT lifelesswks> <20010415222520 DOT E10309 AT redhat DOT com>
Subject: dll_entry [was Re: fork expert needed: (was .....])
Date: Mon, 16 Apr 2001 22:34:22 +0930
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

This is a multi-part message in MIME format.

------=_NextPart_000_035B_01C0C6C5.6251AA30
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

----- Original Message -----
From: "Christopher Faylor" <cgf AT redhat DOT com>
>
> > Robert Collins wrote:
> >Also while MSDN states that only one thread at a time can call the
> >entry point function, it does not state or imply that other threads are
> >suspended during that process.
>
> Ok, I reluctantly stand corrected.  I thought that both the MSDN and
> my own personal experience (waiting for a signal from Cygwi's signal
> thread that never arrived) said this.  I couldn't find any reference
> to this, though.

Moved thread  location.....

The system serializes calls to the dll entry point function and "it
suspends" the other related threads during the process.
(Jeffery Richer - Microsoft Press)

The attached patch can avoid the bottleneck but it may introduce new/old
problems.

Part of the patch is a reversal of a previous patch
http://sources.redhat.com/ml/cygwin-cvs/2000-q2/msg00041.html
What was the purpose of this patch?

Calling DisableThreadLibraryCalls could provide a cheap performance boost by
telling the system to not send DLL_THREAD_ATTACH and DLL_THREAD_DETACH
notifications to dll_entry when creating and destroying threads.

Any thoughts / has it been tried before / a bad idea ?

Regards Trevor





------=_NextPart_000_035B_01C0C6C5.6251AA30
Content-Type: application/octet-stream;
	name="dll-init.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="dll-init.patch"

Index: cygwin/debug.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cygwin/debug.cc,v=0A=
retrieving revision 1.18=0A=
diff -u -3 -p -r1.18 debug.cc=0A=
--- cygwin/debug.cc 2001/03/03 03:56:34 1.18=0A=
+++ cygwin/debug.cc 2001/04/16 11:04:33=0A=
@@ -89,6 +89,13 @@ thread_stub (VOID *arg)=0A=
   /* Give up our slot in the start_buf array */=0A=
   (void) InterlockedExchange (&((thread_start *) arg)->notavail, 0);=0A=
 =0A=
+  if (user_data->threadinterface)=0A=
+    {=0A=
+    if (!TlsSetValue(user_data->threadinterface->reent_index,=0A=
+       &user_data->threadinterface->reents))=0A=
+       api_fatal("Sig proc MT init failed\n");=0A=
+    }=0A=
+=0A=
   /* Initialize this thread's ability to respond to things like=0A=
      SIGSEGV or SIGFPE. */=0A=
   init_exceptions (&except_entry);=0A=
Index: cygwin/init.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cygwin/init.cc,v=0A=
retrieving revision 1.11=0A=
diff -u -3 -p -r1.11 init.cc=0A=
--- cygwin/init.cc 2000/09/08 02:56:54 1.11=0A=
+++ cygwin/init.cc 2001/04/16 11:04:33=0A=
@@ -25,31 +25,18 @@ WINAPI dll_entry (HANDLE h, DWORD reason=0A=
     case DLL_PROCESS_ATTACH:=0A=
       cygwin_hmodule =3D (HMODULE) h;=0A=
       dynamically_loaded =3D (static_load =3D=3D NULL);=0A=
+=0A=
+   /* Tell the system to not send DLL_THREAD_ATTACH and=0A=
+      DLL_THREAD_DETACH notifications to dll_entry.  Therfore, =0A=
+      performance is increased by reducing overhead and avoiding =0A=
+      serialization when creating and destroying threads. */=0A=
+      DisableThreadLibraryCalls(cygwin_hmodule);=0A=
       break;=0A=
     case DLL_THREAD_ATTACH:=0A=
-      if (user_data->threadinterface)=0A=
-	{=0A=
-	  if (!TlsSetValue(user_data->threadinterface->reent_index,=0A=
-		    &user_data->threadinterface->reents))=0A=
-	    api_fatal("Sig proc MT init failed\n");=0A=
-	}=0A=
       break;=0A=
     case DLL_PROCESS_DETACH:=0A=
       break;=0A=
     case DLL_THREAD_DETACH:=0A=
-#if 0 // FIXME: REINSTATE SOON=0A=
-      waitq *w;=0A=
-      if ((w =3D waitq_storage.get ()) !=3D NULL)=0A=
-	{=0A=
-	  if (w->thread_ev !=3D NULL)=0A=
-	    {=0A=
-	      system_printf ("closing %p", w->thread_ev);=0A=
-	      (void) CloseHandle (w->thread_ev);=0A=
-	    }=0A=
-	  memset (w, 0, sizeof(*w));	// FIXME: memory leak=0A=
-	}=0A=
-	// FIXME: Need to add other per_thread stuff here=0A=
-#endif=0A=
       break;=0A=
     }=0A=
   return 1;=0A=

------=_NextPart_000_035B_01C0C6C5.6251AA30
Content-Type: application/octet-stream;
	name="dll-init.ChangeLog"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="dll-init.ChangeLog"

Sun Apr 16 16:30:00 2001  Trevor Forbes <t4bs AT hotmail DOT com>

	* init.cc (dll_entry): Relocate initialization of mt_interface
	reent stuff. Call DisableThreadLibraryCalls.
	* debug.cc (thread_stub): Move mt_interface stuff here.


------=_NextPart_000_035B_01C0C6C5.6251AA30--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019