[newlib-cygwin] Cygwin: signal: Optimize the priority of the sig thread

Takashi Yano tyan0@sourceware.org
Tue Dec 3 15:05:44 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9a274a967d1fe9a28d0d658749b08e65d09d3ee0

commit 9a274a967d1fe9a28d0d658749b08e65d09d3ee0
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Fri Nov 29 16:58:05 2024 +0900

    Cygwin: signal: Optimize the priority of the sig thread
    
    Previously, the sig thread ran in THREAD_PRIORITY_HIGHEST priority.
    This causes a critical delay in the signal handling in the main
    thread if too many signals are received rapidly and the CPU is very
    busy. In this case, most of the CPU time is allocated to the sig
    thread, so the main thread cannot have a chance of handling signals.
    With this patch, to avoid such a situation, the priority of the sig
    thread is set to THREAD_PRIORITY_NORMAL priority.
    
    Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html
    Fixes: 53ad6f1394aa ("(cygthread::cygthread): Use three only arguments for detached threads, and start the thread via QueueUserAPC/async_create.")
    Reported-by: Christian Franke <Christian.Franke@t-online.de>
    Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>

Diff:
---
 winsup/cygwin/sigproc.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index decc7def0..c74596f31 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -1316,6 +1316,7 @@ wait_sig (VOID *)
 
   hntdll = GetModuleHandle ("ntdll.dll");
 
+  SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_NORMAL);
   for (;;)
     {
       DWORD nb;


More information about the Cygwin-cvs mailing list