diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2017-03-08 17:44:15 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2017-03-08 17:44:15 +0100 |
commit | 51a993c266581ba41f1622abd274d9848a37cf1d (patch) | |
tree | 0d5d98fac369de8b12450fe13e16503868606353 | |
parent | 994a4b7dccabb706c9dca2cd43c37e87f2cfe665 (diff) | |
download | cygnal-51a993c266581ba41f1622abd274d9848a37cf1d.tar.gz cygnal-51a993c266581ba41f1622abd274d9848a37cf1d.tar.bz2 cygnal-51a993c266581ba41f1622abd274d9848a37cf1d.zip |
yield: Don't lower thread priority, it leads to starvation
...and it's not required anymore to have the same effect as the original
code post-XP.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/miscfuncs.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 2117eb978..e2ab7a080 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -85,17 +85,18 @@ check_iovec (const struct iovec *iov, int iovcnt, bool forwrite) void yield () { - int prio = GetThreadPriority (GetCurrentThread ()); - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE); - /* MSDN implies that SleepEx will force scheduling of other threads. + /* MSDN implies that Sleep 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) */ + have this desired effect) + + CV 2017-03-08: Drop lowering the priority. It leads to potential + starvation and it should not be necessary anymore + since Server 2003. See the MSDN Sleep man page. */ Sleep (0L); - SetThreadPriority (GetCurrentThread (), prio); } /* Get a default value for the nice factor. When changing these values, |