From 0dc249751dd6969bd091448120efb13291d1105c Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 29 Oct 2005 20:33:59 +0000 Subject: [PATCH] * exceptions.cc (signal_exit): Eliminate setting of main thread priority since process lock should make that unnecessary. * fork.cc (stack_base): Eliminate. (frok::parent): Subsume stack_base and just set stack stuff here. Report on priority class in debugging output. * spawn.cc (spawn_guts): Report on priority class in debugging output. --- winsup/cygwin/ChangeLog | 9 +++++++++ winsup/cygwin/exceptions.cc | 6 ++---- winsup/cygwin/fork.cc | 18 ++++++------------ winsup/cygwin/spawn.cc | 4 +++- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 34d844ebe..5460fb9bb 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2005-10-29 Christopher Faylor + + * exceptions.cc (signal_exit): Eliminate setting of main thread + priority since process lock should make that unnecessary. + * fork.cc (stack_base): Eliminate. + (frok::parent): Subsume stack_base and just set stack stuff here. + Report on priority class in debugging output. + * spawn.cc (spawn_guts): Report on priority class in debugging output. + 2005-10-29 Christopher Faylor * fork.cc (frok::child): Change order of cleanup prior to return. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index be8fb41d2..fc58bdf22 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1187,10 +1187,8 @@ signal_exit (int rc) if (hExeced || exit_state) myself.exit (rc); - /* We'd like to stop the main thread from executing but when we do that it - causes random, inexplicable hangs. So, instead, we set up the priority - of this thread really high so that it should do its thing and then exit. */ - SetThreadPriority (hMainThread, THREAD_PRIORITY_IDLE); + /* Starve other threads in a vain attempt to stop them from doing something + stupid. */ SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL); user_data->resourcelocks->Delete (); diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 4f481b0f8..31d2a10b5 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -55,17 +55,6 @@ class frok friend int fork (); }; -static void -stack_base (child_info_fork *ch) -{ - ch->stackbottom = _tlsbase; - ch->stacktop = &ch; - ch->stacksize = (char *) ch->stackbottom - (char *) &ch; - debug_printf ("bottom %p, top %p, stack %p, size %d, reserve %d", - ch->stackbottom, ch->stacktop, &ch, ch->stacksize, - (char *) ch->stackbottom - (char *) ch->stacktop); -} - /* Copy memory from parent to child. The result is a boolean indicating success. */ @@ -299,6 +288,7 @@ frok::parent (void *stack_here) pthread::atforkprepare (); int c_flags = GetPriorityClass (hMainProc); + debug_printf ("priority class %d", c_flags); STARTUPINFO si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL}; /* If we don't have a console, then don't create a console for the @@ -342,7 +332,11 @@ frok::parent (void *stack_here) ch.forker_finished = forker_finished; - stack_base (&ch); + ch.stackbottom = _tlsbase; + ch.stacktop = stack_here; + ch.stacksize = (char *) ch.stackbottom - (char *) stack_here; + debug_printf ("stack - bottom %p, top %p, size %d", + ch.stackbottom, ch.stacktop, ch.stacksize); si.cb = sizeof (STARTUPINFO); si.lpReserved2 = (LPBYTE) &ch; diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 352d408d1..463ec48fa 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -576,7 +576,9 @@ spawn_guts (const char * prog_arg, const char *const *argv, si.hStdError = handle (2, 1); /* Get output handle */ si.cb = sizeof (si); - int flags = CREATE_DEFAULT_ERROR_MODE | GetPriorityClass (hMainProc) | CREATE_SEPARATE_WOW_VDM; + int flags = GetPriorityClass (hMainProc); + sigproc_printf ("priority class %d", flags); + flags |= CREATE_DEFAULT_ERROR_MODE | CREATE_SEPARATE_WOW_VDM; if (mode == _P_DETACH || !set_console_state_for_spawn ()) flags |= DETACHED_PROCESS; -- 2.43.5