Mail Archives: cygwin-developers/2001/04/16/09:05:05
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 -