This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Make busy waiting loop in exceptions.cc (try_to_debug) less busy.
- From: Vaclav Haisman <V dot Haisman at sh dot cvut dot cz>
- To: cygwin-patches at cygwin dot com
- Date: Fri, 7 Feb 2003 15:35:12 +0100 (CET)
- Subject: Make busy waiting loop in exceptions.cc (try_to_debug) less busy.
Hi,
this patch makes busy waiting loop in try_to_debug less busy by lowering
priority of current thread to idle and by giving up time slices with Sleep(0).
Without this patch it takes tens of seconds to start dumper or gdb because this
busy loop eats whole CPU and computer almost stops responding. With this patch
dumper/gdb starts (almost) immediately. You can test it yourselves with this
simple programm:
int main ()
{
throw 1;
}
Vaclav Haisman
PS: Assignment has been snailed.
2003-02-07 Vaclav Haisman <V.Haisman@sh.cvut.cz>
* exceptions.cc (try_to_debug): Set priority of current thread to
idle. Make busy waiting loop less busy.
Index: cygwin/exceptions.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/exceptions.cc,v
retrieving revision 1.140
diff -u -p -r1.140 exceptions.cc
--- cygwin/exceptions.cc 4 Feb 2003 03:01:17 -0000 1.140
+++ cygwin/exceptions.cc 7 Feb 2003 14:08:57 -0000
@@ -392,10 +392,11 @@ try_to_debug (bool waitloop)
else
{
SetThreadPriority (hMainThread, THREAD_PRIORITY_IDLE);
+ SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
if (!waitloop)
return 1;
while (!being_debugged ())
- /* spin */;
+ Sleep (0);
Sleep (4000);
small_printf ("*** continuing from debugger call\n");
}