https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e9fdf6f420090a800f3e41dd730d53c0cf5b5f8b
commit e9fdf6f420090a800f3e41dd730d53c0cf5b5f8b Author: Takashi Yano <takashi.y...@nifty.ne.jp> AuthorDate: Fri Nov 29 16:58:05 2024 +0900 Commit: Corinna Vinschen <cori...@vinschen.de> CommitDate: Fri Dec 6 11:42:43 2024 +0100 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.fra...@t-online.de> Reviewed-by: Corinna Vinschen <cori...@vinschen.de> Signed-off-by: Takashi Yano <takashi.y...@nifty.ne.jp> (cherry picked from commit 9a274a967d1fe9a28d0d658749b08e65d09d3ee0) Diff: --- winsup/cygwin/sigproc.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 601147ff6ce6..3fe6447e54ff 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;