From 13af9a149da1a97fc7845466ce652427a0765944 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 22 Nov 2002 04:43:47 +0000 Subject: * exceptions.cc (sigthread::get_winapi_lock): Just do standard 'give up timeslice' wait. (setup_handler): Revamp YA to attempt to deliver signal multiple times on failure rather than punting to wait_sig. * miscfuncs.cc (low_priority_sleep): Accept INFINITE sleep to mean "don't reset the priority after setting it to idle". Return previous priority. * winsup.h (SLEEP_0_STAY_LOW): Define. (low_priority_sleep): Return an int. * sigproc.h: Define WAIT_SIG_PRIORITY here. * sigproc.cc: Remove WAIT_SIG_PRIORITY definition. --- winsup/cygwin/miscfuncs.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'winsup/cygwin/miscfuncs.cc') diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 9c7ab5434..e58565942 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -292,12 +292,27 @@ sys_mbstowcs (WCHAR *tgt, const char *src, int len) return MultiByteToWideChar (get_cp (), 0, src, -1, tgt, len); } -void __stdcall +int __stdcall low_priority_sleep (DWORD secs) { HANDLE thisthread = GetCurrentThread (); int curr_prio = GetThreadPriority (thisthread); + bool staylow; + if (secs != INFINITE) + staylow = false; + else + { + secs = 0; + staylow = true; + } + + /* Force any threads in normal priority to be scheduled */ + SetThreadPriority (thisthread, THREAD_PRIORITY_NORMAL); + Sleep (0); + SetThreadPriority (thisthread, THREAD_PRIORITY_IDLE); Sleep (secs); - SetThreadPriority (thisthread, curr_prio); + if (!staylow) + SetThreadPriority (thisthread, curr_prio); + return curr_prio; } -- cgit v1.2.3