diff options
author | Christopher Faylor <me@cgf.cx> | 2011-07-06 16:33:30 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2011-07-06 16:33:30 +0000 |
commit | d1204b6378d4a0aa5b5fcce0eff74b716408796c (patch) | |
tree | 9e6eb1c7613d621f13884aa438c28c1e02c6ff9f /winsup/cygwin/miscfuncs.cc | |
parent | fa0b926af9fc374c93a838d93d3f85ad6ea98f54 (diff) | |
download | cygnal-d1204b6378d4a0aa5b5fcce0eff74b716408796c.tar.gz cygnal-d1204b6378d4a0aa5b5fcce0eff74b716408796c.tar.bz2 cygnal-d1204b6378d4a0aa5b5fcce0eff74b716408796c.zip |
* exceptions.cc (CALL_HANDLER_RETRY_INNER): Rename to reflect different
functionality.
(CALL_HANDLER_RETRY_OUTER): New define.
(setup_handler): Add outer loop to signal handler to try harder to deliver the
signal.
* miscfuncs.cc (yield): Drop priority and use SleepEx() to force thread
rescheduling rather than relying on SwitchToThread().
Diffstat (limited to 'winsup/cygwin/miscfuncs.cc')
-rw-r--r-- | winsup/cygwin/miscfuncs.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 0ac25f4c3..d293edea9 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -235,11 +235,21 @@ check_iovec (const struct iovec *iov, int iovcnt, bool forwrite) return (ssize_t) tot; } +/* Try hard to schedule another thread. */ void yield () { - for (int i = 0; i < 3; i++) - SwitchToThread (); + for (int i = 0; i < 2; i++) + { + int prio = GetThreadPriority (GetCurrentThread ()); + SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE); + /* MSDN implies that SleepEx(0,...) 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. */ + SleepEx (0, false); + SetThreadPriority (GetCurrentThread (), prio); + } } /* Get a default value for the nice factor. When changing these values, |