* miscfuncs.cc (yield): Revert (after researching) to calling SleepEx with 0.
We don't want to actually sleep when calling this function.
This commit is contained in:
parent
1eaf9215cb
commit
1952976a1b
@ -1,3 +1,8 @@
|
|||||||
|
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>
|
2013-06-08 Christopher Faylor <me.cygwin2013@cgf.cx>
|
||||||
|
|
||||||
* cygwait.cc (cygwait): Remove lock around sig retrieval since this
|
* cygwait.cc (cygwait): Remove lock around sig retrieval since this
|
||||||
|
@ -237,25 +237,21 @@ check_iovec (const struct iovec *iov, int iovcnt, bool forwrite)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Try hard to schedule another thread.
|
/* Try hard to schedule another thread.
|
||||||
|
Remember not to call this in a lock condition or you'll potentially
|
||||||
Note: Don't call yield under _cygtls::lock conditions. It results in
|
suffer starvation. */
|
||||||
potential starvation, especially on a single-CPU system, because
|
|
||||||
_cygtls::lock also calls yield when waiting for the lock. */
|
|
||||||
void
|
void
|
||||||
yield ()
|
yield ()
|
||||||
{
|
{
|
||||||
int prio = GetThreadPriority (GetCurrentThread ());
|
int prio = GetThreadPriority (GetCurrentThread ());
|
||||||
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
|
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
/* MSDN implies that SleepEx will force scheduling of other threads.
|
/* MSDN implies that SleepEx will force scheduling of other threads.
|
||||||
Unlike SwitchToThread() the documentation does not mention other
|
Unlike SwitchToThread() the documentation does not mention other
|
||||||
cpus so, presumably (hah!), this + using a lower priority will
|
cpus so, presumably (hah!), this + using a lower priority will
|
||||||
stall this thread temporarily and cause another to run.
|
stall this thread temporarily and cause another to run.
|
||||||
Note: Don't use 0 timeout. This takes a lot of CPU if something
|
(stackoverflow and others seem to confirm that setting this thread
|
||||||
goes wrong. */
|
to a lower priority and calling Sleep with a 0 paramenter will
|
||||||
SleepEx (1L, false);
|
have this desired effect) */
|
||||||
}
|
Sleep (0L);
|
||||||
SetThreadPriority (GetCurrentThread (), prio);
|
SetThreadPriority (GetCurrentThread (), prio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user