* 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.
This commit is contained in:
parent
d41ac477ee
commit
d688945c44
|
@ -1,3 +1,11 @@
|
||||||
|
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>
|
2003-08-20 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* speclib: Fix created lib to avoid "File truncated" problems.
|
* speclib: Fix created lib to avoid "File truncated" problems.
|
||||||
|
|
|
@ -306,12 +306,13 @@ low_priority_sleep (DWORD secs)
|
||||||
staylow = true;
|
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 */
|
/* Force any threads in normal priority to be scheduled */
|
||||||
SetThreadPriority (thisthread, THREAD_PRIORITY_NORMAL);
|
SetThreadPriority (thisthread, main_prio);
|
||||||
Sleep (secs);
|
Sleep (secs);
|
||||||
|
|
||||||
if (!staylow || curr_prio == THREAD_PRIORITY_NORMAL)
|
if (!staylow || curr_prio == main_prio)
|
||||||
SetThreadPriority (thisthread, curr_prio);
|
SetThreadPriority (thisthread, curr_prio);
|
||||||
return curr_prio;
|
return curr_prio;
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,20 +682,24 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception)
|
||||||
if (its_me)
|
if (its_me)
|
||||||
{
|
{
|
||||||
if (!wait_for_completion)
|
if (!wait_for_completion)
|
||||||
|
{
|
||||||
thiscatch = sigcatch_nosync;
|
thiscatch = sigcatch_nosync;
|
||||||
|
todo = myself->getsigtodo (sig);
|
||||||
|
}
|
||||||
else if (tid != mainthread.id)
|
else if (tid != mainthread.id)
|
||||||
{
|
{
|
||||||
thiscatch = sigcatch_nonmain;
|
thiscatch = sigcatch_nonmain;
|
||||||
thiscomplete = sigcomplete_nonmain;
|
thiscomplete = sigcomplete_nonmain;
|
||||||
|
todo = getlocal_sigtodo (sig);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
thiscatch = sigcatch_main;
|
thiscatch = sigcatch_main;
|
||||||
thiscomplete = sigcomplete_main;
|
thiscomplete = sigcomplete_main;
|
||||||
thisframe.set (mainthread, ebp, exception);
|
thisframe.set (mainthread, ebp, exception);
|
||||||
}
|
|
||||||
todo = getlocal_sigtodo (sig);
|
todo = getlocal_sigtodo (sig);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (thiscatch = getsem (p, "sigcatch", 0, 0))
|
else if (thiscatch = getsem (p, "sigcatch", 0, 0))
|
||||||
todo = p->getsigtodo (sig);
|
todo = p->getsigtodo (sig);
|
||||||
else
|
else
|
||||||
|
@ -1152,37 +1156,26 @@ wait_sig (VOID *self)
|
||||||
|
|
||||||
rc -= WAIT_OBJECT_0;
|
rc -= WAIT_OBJECT_0;
|
||||||
sigproc_printf ("awake, rc %d", rc);
|
sigproc_printf ("awake, rc %d", rc);
|
||||||
LONG **start_todo, **end_todo;
|
LONG *todo;
|
||||||
switch (rc)
|
if (rc != RC_NOSYNC)
|
||||||
{
|
todo = *todos;
|
||||||
case RC_MAIN:
|
else
|
||||||
case RC_NONMAIN:
|
todo = todos[1];
|
||||||
start_todo = todos;
|
|
||||||
end_todo = todos;
|
|
||||||
break;
|
|
||||||
case RC_NOSYNC:
|
|
||||||
default: // silence compiler warning
|
|
||||||
start_todo = todos + 1;
|
|
||||||
end_todo = todos + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A sigcatch semaphore has been signaled. Scan the sigtodo
|
/* A sigcatch semaphore has been signaled. Scan the sigtodo
|
||||||
* array looking for any unprocessed signals.
|
* array looking for any unprocessed signals.
|
||||||
*/
|
*/
|
||||||
pending_signals = 0;
|
pending_signals = false;
|
||||||
bool saw_failed_interrupt = 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++)
|
for (int sig = -__SIGOFFSET; sig < NSIG; sig++)
|
||||||
{
|
{
|
||||||
LONG x = InterlockedDecrement (*todo + sig);
|
LONG x = InterlockedDecrement (todo + sig);
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
InterlockedIncrement (*todo + sig);
|
InterlockedIncrement (todo + sig);
|
||||||
else if (x >= 0)
|
else if (x >= 0)
|
||||||
{
|
{
|
||||||
if (x > 0)
|
|
||||||
pending_signals = true; /* semaphore should already be armed */
|
|
||||||
|
|
||||||
if (sig > 0 && sig != SIGKILL && sig != SIGSTOP &&
|
if (sig > 0 && sig != SIGKILL && sig != SIGSTOP &&
|
||||||
(sigismember (&myself->getsigmask (), sig) ||
|
(sigismember (&myself->getsigmask (), sig) ||
|
||||||
main_vfork->pid ||
|
main_vfork->pid ||
|
||||||
|
@ -1195,6 +1188,9 @@ wait_sig (VOID *self)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Found a signal to process */
|
/* 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);
|
sigproc_printf ("processing signal %d", sig);
|
||||||
switch (sig)
|
switch (sig)
|
||||||
{
|
{
|
||||||
|
@ -1221,20 +1217,22 @@ wait_sig (VOID *self)
|
||||||
sigproc_printf ("Got signal %d", sig);
|
sigproc_printf ("Got signal %d", sig);
|
||||||
if (!sig_handle (sig))
|
if (!sig_handle (sig))
|
||||||
{
|
{
|
||||||
|
pending_signals = saw_failed_interrupt = true;
|
||||||
sigproc_printf ("couldn't send signal %d", sig);
|
sigproc_printf ("couldn't send signal %d", sig);
|
||||||
ReleaseSemaphore (sigcatch_nosync, 1, NULL);
|
|
||||||
saw_failed_interrupt = true;
|
|
||||||
pending_signals = true;
|
|
||||||
InterlockedIncrement (myself->getsigtodo (sig));
|
InterlockedIncrement (myself->getsigtodo (sig));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (rc == RC_NOSYNC)
|
||||||
|
more_signals = x > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sig == SIGCHLD)
|
if (sig == SIGCHLD)
|
||||||
proc_subproc (PROC_CLEARWAIT, 0);
|
proc_subproc (PROC_CLEARWAIT, 0);
|
||||||
|
if (saw_failed_interrupt || rc != RC_NOSYNC)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while (more_signals);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
/* Signal completion of signal handling depending on which semaphore
|
/* Signal completion of signal handling depending on which semaphore
|
||||||
|
@ -1249,7 +1247,10 @@ wait_sig (VOID *self)
|
||||||
}
|
}
|
||||||
out1:
|
out1:
|
||||||
if (saw_failed_interrupt)
|
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");
|
sigproc_printf ("looping");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue