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
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-08-21 07:18:46 +0400
committerChristopher Faylor <me@cgf.cx>2003-08-21 07:18:46 +0400
commitd688945c445857ac67704822d07522b91957be07 (patch)
tree6f13cc259c9709302014a07656063689b7c9c66d /winsup/cygwin
parentd41ac477eeca78c49ed31959882e8d705e93d4a1 (diff)
* miscfuncs.cc (low_priority_sleep): Sleep at same priority as main thread.
* sigproc.cc (wait_sig): Keep looping if there are more signals to consider and we are flushing signals. (sig_send): Put nonsync signals in the correct bucket.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/miscfuncs.cc7
-rw-r--r--winsup/cygwin/sigproc.cc57
3 files changed, 41 insertions, 31 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 03a7ed515..e8f77acc6 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,13 @@
2003-08-20 Christopher Faylor <cgf@redhat.com>
+ * miscfuncs.cc (low_priority_sleep): Sleep at same priority as main
+ thread.
+ * sigproc.cc (wait_sig): Keep looping if there are more signals to
+ consider and we are flushing signals.
+ (sig_send): Put nonsync signals in the correct bucket.
+
+2003-08-20 Christopher Faylor <cgf@redhat.com>
+
* speclib: Fix created lib to avoid "File truncated" problems.
2003-08-20 Pierre Humblet <pierre.humblet@ieee.org>
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index 6956d38be..fea1b1249 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -306,12 +306,13 @@ low_priority_sleep (DWORD secs)
staylow = true;
}
- if (curr_prio != THREAD_PRIORITY_NORMAL)
+ int main_prio = GetThreadPriority (hMainThread);
+ if (curr_prio != main_prio)
/* Force any threads in normal priority to be scheduled */
- SetThreadPriority (thisthread, THREAD_PRIORITY_NORMAL);
+ SetThreadPriority (thisthread, main_prio);
Sleep (secs);
- if (!staylow || curr_prio == THREAD_PRIORITY_NORMAL)
+ if (!staylow || curr_prio == main_prio)
SetThreadPriority (thisthread, curr_prio);
return curr_prio;
}
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 1b8d96805..fe1441dcf 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -682,19 +682,23 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception)
if (its_me)
{
if (!wait_for_completion)
- thiscatch = sigcatch_nosync;
+ {
+ thiscatch = sigcatch_nosync;
+ todo = myself->getsigtodo (sig);
+ }
else if (tid != mainthread.id)
{
thiscatch = sigcatch_nonmain;
thiscomplete = sigcomplete_nonmain;
+ todo = getlocal_sigtodo (sig);
}
else
{
thiscatch = sigcatch_main;
thiscomplete = sigcomplete_main;
thisframe.set (mainthread, ebp, exception);
+ todo = getlocal_sigtodo (sig);
}
- todo = getlocal_sigtodo (sig);
}
else if (thiscatch = getsem (p, "sigcatch", 0, 0))
todo = p->getsigtodo (sig);
@@ -1152,37 +1156,26 @@ wait_sig (VOID *self)
rc -= WAIT_OBJECT_0;
sigproc_printf ("awake, rc %d", rc);
- LONG **start_todo, **end_todo;
- switch (rc)
- {
- case RC_MAIN:
- case RC_NONMAIN:
- start_todo = todos;
- end_todo = todos;
- break;
- case RC_NOSYNC:
- default: // silence compiler warning
- start_todo = todos + 1;
- end_todo = todos + 1;
- break;
- }
+ LONG *todo;
+ if (rc != RC_NOSYNC)
+ todo = *todos;
+ else
+ todo = todos[1];
/* A sigcatch semaphore has been signaled. Scan the sigtodo
* array looking for any unprocessed signals.
*/
- pending_signals = 0;
+ pending_signals = false;
bool saw_failed_interrupt = false;
- for (LONG **todo = todos; todo <= end_todo; todo++)
+ bool more_signals = false;
+ do
for (int sig = -__SIGOFFSET; sig < NSIG; sig++)
{
- LONG x = InterlockedDecrement (*todo + sig);
+ LONG x = InterlockedDecrement (todo + sig);
if (x < 0)
- InterlockedIncrement (*todo + sig);
+ InterlockedIncrement (todo + sig);
else if (x >= 0)
{
- if (x > 0)
- pending_signals = true; /* semaphore should already be armed */
-
if (sig > 0 && sig != SIGKILL && sig != SIGSTOP &&
(sigismember (&myself->getsigmask (), sig) ||
main_vfork->pid ||
@@ -1195,6 +1188,9 @@ wait_sig (VOID *self)
else
{
/* Found a signal to process */
+ if (rc != RC_NOSYNC)
+ pending_signals = true; // There should be an armed semaphore, in this case
+
sigproc_printf ("processing signal %d", sig);
switch (sig)
{
@@ -1221,20 +1217,22 @@ wait_sig (VOID *self)
sigproc_printf ("Got signal %d", sig);
if (!sig_handle (sig))
{
+ pending_signals = saw_failed_interrupt = true;
sigproc_printf ("couldn't send signal %d", sig);
- ReleaseSemaphore (sigcatch_nosync, 1, NULL);
- saw_failed_interrupt = true;
- pending_signals = true;
InterlockedIncrement (myself->getsigtodo (sig));
}
}
+ if (rc == RC_NOSYNC)
+ more_signals = x > 0;
}
if (sig == SIGCHLD)
proc_subproc (PROC_CLEARWAIT, 0);
- goto out;
+ if (saw_failed_interrupt || rc != RC_NOSYNC)
+ goto out;
}
}
+ while (more_signals);
out:
/* Signal completion of signal handling depending on which semaphore
@@ -1249,7 +1247,10 @@ wait_sig (VOID *self)
}
out1:
if (saw_failed_interrupt)
- low_priority_sleep (SLEEP_0_STAY_LOW); /* Hopefully, other thread will be waking up soon. */
+ {
+ ReleaseSemaphore (sigcatch_nosync, 1, NULL);
+ low_priority_sleep (0); /* Hopefully, other thread will be waking up soon. */
+ }
sigproc_printf ("looping");
}