diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2013-06-06 15:29:41 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2013-06-06 15:29:41 +0000 |
commit | b3f0fb6baade0d496286973ffef8907bccf04193 (patch) | |
tree | 89879705491d949fe6015f9406d201f9aa6e1ffc /winsup/cygwin/exceptions.cc | |
parent | 925e1c815788349f5d5a4ecbfcf0f0ed66c3585e (diff) | |
download | cygnal-b3f0fb6baade0d496286973ffef8907bccf04193.tar.gz cygnal-b3f0fb6baade0d496286973ffef8907bccf04193.tar.bz2 cygnal-b3f0fb6baade0d496286973ffef8907bccf04193.zip |
* exceptions.cc (_cygtls::handle_SIGCONT): Simplify loop waiting for
sig_handle_tty_stop to wake up. Make sure to unlock before calling
yield to avoid starvation of sig_handle_tty_stop. Add comments.
* miscfuncs.cc (yield): Explain why yield should never be called under
_cygtls::lock conditions. Call SleepEx with 1ms timeout. Explain why.
Diffstat (limited to 'winsup/cygwin/exceptions.cc')
-rw-r--r-- | winsup/cygwin/exceptions.cc | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index abb973528..aa0036a18 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1253,25 +1253,18 @@ _cygtls::handle_SIGCONT () { myself->stopsig = 0; myself->process_state &= ~PID_STOPPED; - int state = 0; /* Carefully tell sig_handle_tty_stop to wake up. */ - while (state < 2) - { - lock (); - if (sig) - yield (); /* state <= 1 */ - else if (state) - state++; /* state == 2 */ - else - { - sig = SIGCONT; - SetEvent (signal_arrived); - state++; /* state == 1 */ - } - unlock (); - } + lock (); + sig = SIGCONT; + SetEvent (signal_arrived); + /* Make sure yield doesn't run under lock condition to avoid + starvation of sig_handle_tty_stop. */ + unlock (); + /* Wait until sig_handle_tty_stop woke up. */ + while (sig) + yield (); /* Tell wait_sig to handle any queued signals now that we're alive - again. */ + again. */ sig_dispatch_pending (false); } /* Clear pending stop signals */ |