On Nov 29 20:59, Takashi Yano wrote:
> This patch calls Sleep(0) in the wait loop in lock() to increase the
> chance of being unlocked in other threads. The lock(), unlock() and
> locked() are moved from sigfe.s to cygtls.h so that allows inline
> expansion.
> 
> Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html
> Fixes: 61522196c715 ("* Merge in cygwin-64bit-branch.")
> 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>
> ---
>  winsup/cygwin/local_includes/cygtls.h | 17 ++++++++++---
>  winsup/cygwin/scripts/gendef          | 36 ---------------------------
>  2 files changed, 13 insertions(+), 40 deletions(-)
> 
> diff --git a/winsup/cygwin/local_includes/cygtls.h 
> b/winsup/cygwin/local_includes/cygtls.h
> index e5a377d6b..57a0ec042 100644
> --- a/winsup/cygwin/local_includes/cygtls.h
> +++ b/winsup/cygwin/local_includes/cygtls.h
> @@ -197,7 +197,7 @@ public: /* Do NOT remove this public: line, it's a marker 
> for gentls_offsets. */
>    int current_sig;
>    unsigned incyg;
>    unsigned spinning;
> -  unsigned stacklock;
> +  volatile unsigned stacklock;
>    __tlsstack_t *stackptr;
>    __tlsstack_t stack[TLS_STACK_SIZE];
>    unsigned initialized;
> @@ -225,9 +225,18 @@ public: /* Do NOT remove this public: line, it's a 
> marker for gentls_offsets. */
>    int call_signal_handler ();
>    void remove_wq (DWORD);
>    void fixup_after_fork ();
> -  void lock ();
> -  void unlock ();
> -  bool locked ();
> +  void lock ()
> +  {
> +    while (InterlockedExchange (&stacklock, 1))
> +      {
> +#ifdef __x86_64__
> +     __asm__ ("pause");

At this point, add an #else / ##error unimplemented for this target

With this, the patch is GTG.  Just push it.


Thanks,
Corinna

Reply via email to