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
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-06-08 20:39:52 +0400
committerChristopher Faylor <me@cgf.cx>2013-06-08 20:39:52 +0400
commit1952976a1b807d0d273de902003c79af0eb4f56c (patch)
tree3fe8283d3f70338d3f38066767712f7b6ab26cef /winsup
parent1eaf9215cb27dc368598e5937533411c360fddc9 (diff)
* miscfuncs.cc (yield): Revert (after researching) to calling SleepEx with 0.
We don't want to actually sleep when calling this function.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/miscfuncs.cc26
2 files changed, 16 insertions, 15 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 992d5a7ef..a32a28a2d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,10 @@
2013-06-08 Christopher Faylor <me.cygwin2013@cgf.cx>
+ * miscfuncs.cc (yield): Revert (after researching) to calling SleepEx
+ with 0. We don't want to actually sleep when calling this function.
+
+2013-06-08 Christopher Faylor <me.cygwin2013@cgf.cx>
+
* cygwait.cc (cygwait): Remove lock around sig retrieval since this
code is essentially guarded by thread-specific signal_arrived.
* exceptions.cc (_cygtls::handle_SIGCONT): Simplify. Eliminate
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index d0748ea6c..819eaa54e 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -236,26 +236,22 @@ check_iovec (const struct iovec *iov, int iovcnt, bool forwrite)
return (ssize_t) tot;
}
-/* Try hard to schedule another thread.
-
- Note: Don't call yield under _cygtls::lock conditions. It results in
- potential starvation, especially on a single-CPU system, because
- _cygtls::lock also calls yield when waiting for the lock. */
+/* Try hard to schedule another thread.
+ Remember not to call this in a lock condition or you'll potentially
+ suffer starvation. */
void
yield ()
{
int prio = GetThreadPriority (GetCurrentThread ());
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
- for (int i = 0; i < 2; i++)
- {
- /* MSDN implies that SleepEx will force scheduling of other threads.
- Unlike SwitchToThread() the documentation does not mention other
- cpus so, presumably (hah!), this + using a lower priority will
- stall this thread temporarily and cause another to run.
- Note: Don't use 0 timeout. This takes a lot of CPU if something
- goes wrong. */
- SleepEx (1L, false);
- }
+ /* MSDN implies that SleepEx will force scheduling of other threads.
+ Unlike SwitchToThread() the documentation does not mention other
+ cpus so, presumably (hah!), this + using a lower priority will
+ stall this thread temporarily and cause another to run.
+ (stackoverflow and others seem to confirm that setting this thread
+ to a lower priority and calling Sleep with a 0 paramenter will
+ have this desired effect) */
+ Sleep (0L);
SetThreadPriority (GetCurrentThread (), prio);
}