[PATCH 6/6] Cygwin: cygtls: Prompt system to switch tasks explicitly in lock()
Takashi Yano
takashi.yano@nifty.ne.jp
Mon Nov 25 12:16:22 GMT 2024
This patch replaces pause instruction with SwitchToThread() call
in wait loop in lock() to increase the chance to unlock in other
threads.
Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html
Fixes: 61522196c715 ("* Merge in cygwin-64bit-branch.")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Reviewed-by:
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
---
winsup/cygwin/scripts/gendef | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
index 720325fdd..d1bcc5318 100755
--- a/winsup/cygwin/scripts/gendef
+++ b/winsup/cygwin/scripts/gendef
@@ -115,6 +115,8 @@ EOF
.include "tlsoffsets"
.text
+ .global SwitchToThread
+
.seh_proc _sigfe_maybe
_sigfe_maybe: # stack is aligned on entry!
.seh_endprologue
@@ -334,7 +336,7 @@ _ZN7_cygtls4lockEv:
xchgl %r11d,_cygtls.stacklock_p(%r12) # try to acquire lock
testl %r11d,%r11d
jz 2f
- pause
+ call SwitchToThread
jmp 1b
2: popq %r12
ret
--
2.45.1
More information about the Cygwin-patches
mailing list