Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2011-07-31 00:50:23 +0400
committerChristopher Faylor <me@cgf.cx>2011-07-31 00:50:23 +0400
commit53ad6f1394aa625e4b75a29e010651e22770e367 (patch)
tree55b4385d09ada46d2b4966c726f946c444544504
parentf7e198a665edf1b4d553be353999b4e1b7075c3a (diff)
* cygthread.cc (cygthread::async_create): Define new function.
* cygthread.h (cygthread::create): Use correct regparm. (cygthread::standalone): Delete from class and from all constructors. (cygthread::cygthread): Use three only arguments for detached threads, and start the thread via QueueUserAPC/async_create. * dcrt0.cc (dll_crt0_0): Remove handling for wincap.has_buggy_thread_startup. (dll_crt0_1): Ditto. * wincap.cc: Ditto throughout. * wincap.h: Ditto.
-rw-r--r--winsup/cygwin/ChangeLog13
-rw-r--r--winsup/cygwin/cygthread.cc11
-rw-r--r--winsup/cygwin/cygthread.h26
-rw-r--r--winsup/cygwin/dcrt0.cc5
-rw-r--r--winsup/cygwin/wincap.cc10
-rw-r--r--winsup/cygwin/wincap.h2
6 files changed, 37 insertions, 30 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 66d44fdff..e9ff293d9 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,18 @@
2011-07-30 Christopher Faylor <me.cygwin2011@cgf.cx>
+ * cygthread.cc (cygthread::async_create): Define new function.
+ * cygthread.h (cygthread::create): Use correct regparm.
+ (cygthread::standalone): Delete from class and from all constructors.
+ (cygthread::cygthread): Use three only arguments for detached threads,
+ and start the thread via QueueUserAPC/async_create.
+ * dcrt0.cc (dll_crt0_0): Remove handling for
+ wincap.has_buggy_thread_startup.
+ (dll_crt0_1): Ditto.
+ * wincap.cc: Ditto throughout.
+ * wincap.h: Ditto.
+
+2011-07-30 Christopher Faylor <me.cygwin2011@cgf.cx>
+
* fhandler.h (fhandler_base_overlapped::size): Declare/define size()
function for consistency.
(fhandler_termios::size): Ditto.
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc
index ef8a4d575..50a265b4b 100644
--- a/winsup/cygwin/cygthread.cc
+++ b/winsup/cygwin/cygthread.cc
@@ -186,6 +186,17 @@ out:
return info;
}
+/* This function is called via QueueUserAPC. Apparently creating threads
+ asynchronously is a huge performance win on Win64. */
+void CALLBACK
+cygthread::async_create (ULONG_PTR arg)
+{
+ cygthread *that = (cygthread *) arg;
+ that->create ();
+ ::SetThreadPriority (that->h, THREAD_PRIORITY_HIGHEST);
+ that->zap_h ();
+}
+
void
cygthread::create ()
{
diff --git a/winsup/cygwin/cygthread.h b/winsup/cygwin/cygthread.h
index 7f3869220..9950873ee 100644
--- a/winsup/cygwin/cygthread.h
+++ b/winsup/cygwin/cygthread.h
@@ -31,8 +31,8 @@ class cygthread
bool is_freerange;
static bool exiting;
HANDLE notify_detached;
- bool standalone;
- void create () __attribute__ ((regparm(2)));
+ void create () __attribute__ ((regparm (1)));
+ static void CALLBACK async_create (ULONG_PTR);
public:
bool terminate_thread ();
static DWORD WINAPI stub (VOID *);
@@ -44,33 +44,27 @@ class cygthread
void release (bool);
cygthread (LPTHREAD_START_ROUTINE start, unsigned n, LPVOID param, const char *name, HANDLE notify = NULL)
: __name (name), func (start), arglen (n), arg (param),
- notify_detached (notify), standalone (false)
+ notify_detached (notify)
{
create ();
}
- cygthread (LPVOID_THREAD_START_ROUTINE start, LPVOID param, const char *name, HANDLE notify = NULL)
+ cygthread (LPVOID_THREAD_START_ROUTINE start, LPVOID param, const char *name)
: __name (name), func ((LPTHREAD_START_ROUTINE) start), arglen (0),
- arg (param), notify_detached (notify), standalone (true)
+ arg (param), notify_detached (NULL)
{
- create ();
- /* This is a neverending/high-priority thread */
- ::SetThreadPriority (h, THREAD_PRIORITY_HIGHEST);
- zap_h ();
+ QueueUserAPC (async_create, GetCurrentThread (), (ULONG_PTR) this);
}
cygthread (LPTHREAD_START_ROUTINE start, LPVOID param, const char *name, HANDLE notify = NULL)
: __name (name), func (start), arglen (0), arg (param),
- notify_detached (notify), standalone (false)
+ notify_detached (notify)
{
create ();
}
- cygthread (LPVOID_THREAD_START_ROUTINE start, unsigned n, LPVOID param, const char *name, HANDLE notify = NULL)
+ cygthread (LPVOID_THREAD_START_ROUTINE start, unsigned n, LPVOID param, const char *name)
: __name (name), func ((LPTHREAD_START_ROUTINE) start), arglen (n),
- arg (param), notify_detached (notify), standalone (true)
+ arg (param), notify_detached (NULL)
{
- create ();
- /* This is a neverending/high-priority thread */
- ::SetThreadPriority (h, THREAD_PRIORITY_HIGHEST);
- zap_h ();
+ QueueUserAPC (async_create, GetCurrentThread (), (ULONG_PTR) this);
}
cygthread () {};
static void init ();
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 017faa692..32a5bc1d6 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -709,7 +709,7 @@ dll_crt0_0 ()
/* Initialize signal processing here, early, in the hopes that the creation
of a thread early in the process will cause more predictability in memory
layout for the main thread. */
- if (!wincap.has_buggy_thread_startup () && !dynamically_loaded)
+ if (!dynamically_loaded)
sigproc_init ();
debug_printf ("finished dll_crt0_0 initialization");
@@ -724,8 +724,9 @@ dll_crt0_1 (void *)
{
extern void initial_setlocale ();
- if (wincap.has_buggy_thread_startup () || dynamically_loaded)
+ if (dynamically_loaded)
sigproc_init ();
+
check_sanity_and_sync (user_data);
/* Initialize malloc and then call user_shared_initialize since it relies
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index 2a848b4b6..25acbf3f4 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -47,7 +47,6 @@ wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_broken_alloc_console:false,
has_always_all_codepages:false,
has_localenames:false,
- has_buggy_thread_startup:false,
has_fast_cwd:false,
has_restricted_raw_disk_access:false,
use_dont_resolve_hack:false,
@@ -78,7 +77,6 @@ wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) =
has_broken_alloc_console:false,
has_always_all_codepages:false,
has_localenames:false,
- has_buggy_thread_startup:false,
has_fast_cwd:false,
has_restricted_raw_disk_access:false,
use_dont_resolve_hack:false,
@@ -109,7 +107,6 @@ wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
has_broken_alloc_console:false,
has_always_all_codepages:false,
has_localenames:false,
- has_buggy_thread_startup:false,
has_fast_cwd:false,
has_restricted_raw_disk_access:false,
use_dont_resolve_hack:true,
@@ -140,7 +137,6 @@ wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_broken_alloc_console:false,
has_always_all_codepages:false,
has_localenames:false,
- has_buggy_thread_startup:false,
has_fast_cwd:false,
has_restricted_raw_disk_access:false,
use_dont_resolve_hack:true,
@@ -171,7 +167,6 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_broken_alloc_console:false,
has_always_all_codepages:false,
has_localenames:false,
- has_buggy_thread_startup:false,
has_fast_cwd:false,
has_restricted_raw_disk_access:false,
use_dont_resolve_hack:true,
@@ -202,7 +197,6 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_broken_alloc_console:false,
has_always_all_codepages:false,
has_localenames:false,
- has_buggy_thread_startup:false,
has_fast_cwd:false,
has_restricted_raw_disk_access:false,
use_dont_resolve_hack:true,
@@ -233,7 +227,6 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
has_broken_alloc_console:false,
has_always_all_codepages:true,
has_localenames:true,
- has_buggy_thread_startup:true,
has_fast_cwd:true,
has_restricted_raw_disk_access:true,
use_dont_resolve_hack:false,
@@ -264,7 +257,6 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_broken_alloc_console:true,
has_always_all_codepages:true,
has_localenames:true,
- has_buggy_thread_startup:false,
has_fast_cwd:true,
has_restricted_raw_disk_access:true,
use_dont_resolve_hack:false,
@@ -358,8 +350,6 @@ wincapc::init ()
((wincaps *)caps)->has_restricted_stack_args = false;
}
- if (!wow64)
- ((wincaps *) caps)->has_buggy_thread_startup = false;
__small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion,
version.dwMinorVersion);
}
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index 7738d1f8b..eab78fd03 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -37,7 +37,6 @@ struct wincaps
unsigned has_broken_alloc_console : 1;
unsigned has_always_all_codepages : 1;
unsigned has_localenames : 1;
- unsigned has_buggy_thread_startup : 1;
unsigned has_fast_cwd : 1;
unsigned has_restricted_raw_disk_access : 1;
unsigned use_dont_resolve_hack : 1;
@@ -87,7 +86,6 @@ public:
bool IMPLEMENT (has_broken_alloc_console)
bool IMPLEMENT (has_always_all_codepages)
bool IMPLEMENT (has_localenames)
- bool IMPLEMENT (has_buggy_thread_startup)
bool IMPLEMENT (has_fast_cwd)
bool IMPLEMENT (has_restricted_raw_disk_access)
bool IMPLEMENT (use_dont_resolve_hack)