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>2010-03-13 02:13:48 +0300
committerChristopher Faylor <me@cgf.cx>2010-03-13 02:13:48 +0300
commit084ea5108e86738a09288268b186541b0c23920a (patch)
tree93ad21c3c750fe12e7792ff8679b87888992dc3d /winsup/cygwin/miscfuncs.cc
parent36960dec3721fccc8eb931787a2656cf715bfc39 (diff)
Throughout change all calls of low_priority_sleep (0) to yield ().
* miscfuncs.cc (yield): Rename from low_priority_sleep. Remove all of the logic which called Sleep() and just use SwitchToThread. * miscfuncs.h (yield): Rename from low_priority_sleep. (SLEEP_0_STAY_LOW): Delete unused define. * shared.cc (memory_init): Move heap_init() call directly after shared memory initialization to more closely mimic long-standing program flow. * tty.cc (tty_list::terminate): Replace call to low_priority_sleep with Sleep.
Diffstat (limited to 'winsup/cygwin/miscfuncs.cc')
-rw-r--r--winsup/cygwin/miscfuncs.cc40
1 files changed, 4 insertions, 36 deletions
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index 29b8159ad..c7099dc9b 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -228,43 +228,11 @@ check_iovec (const struct iovec *iov, int iovcnt, bool forwrite)
return (ssize_t) tot;
}
-extern "C" int
-low_priority_sleep (DWORD secs)
+void
+yield ()
{
- HANDLE thisthread = GetCurrentThread ();
- int curr_prio = GetThreadPriority (thisthread);
- bool staylow;
- if (secs != INFINITE)
- staylow = false;
- else
- {
- secs = 0;
- staylow = true;
- }
-
- if (!secs)
- {
- for (int i = 0; i < 3; i++)
- SwitchToThread ();
- }
- else
- {
- int new_prio;
- if (GetCurrentThreadId () == cygthread::main_thread_id)
- new_prio = THREAD_PRIORITY_LOWEST;
- else
- new_prio = GetThreadPriority (hMainThread);
-
- if (curr_prio != new_prio)
- /* Force any threads in normal priority to be scheduled */
- SetThreadPriority (thisthread, new_prio);
- Sleep (secs);
-
- if (!staylow && curr_prio != new_prio)
- SetThreadPriority (thisthread, curr_prio);
- }
-
- return curr_prio;
+ for (int i = 0; i < 3; i++)
+ SwitchToThread ();
}
/* Get a default value for the nice factor. When changing these values,