DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 44U90Y6E2029181
Authentication-Results: delorie.com;
	dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=qdN8j+VK
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D86F3858417
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1717059632;
	bh=SZUVBHZBLg6uXAOXo7XspCMfKP34imXO2BSljxO+v0E=;
	h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=qdN8j+VKrZbhneqXoOvbCR3zA06wSGo2zUskWGXVYv77D06JUiNHjdy0hbN1mmKsG
	 hCXbdTiObjFVA+wJbY5OSEe3MqOzX/Ak1rzRwSeSPczdaG4PU9lcBNyCEmQW2boszQ
	 QNdUr2i9/pqaLyIwo8lnWkm2vAIP1oRC6J5VHeMY=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DD35C3858D20
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DD35C3858D20
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717059605; cv=none;
 b=VFEY31gZwQVAoG7EB9mwbxzLIcpfPaUkzxOsbYYPIYXo29HB7I/3pIanApngdu7u/jHWGYI5fZ47fgBX8i4y2chALuTrrakpNKdAEmDAuWaDs8GeZZN58e6T0gxXiBwSHhF1/lZH0UXypIjj5m1VgKFkY2pqZZ1rm0zx1iGLA6A=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1717059605; c=relaxed/simple;
 bh=jNJBE5eWSN3ipV2YYtdp44bpWLifXHppAVFGOer5Alk=;
 h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;
 b=gn4HJgUQmQZ7J5u6irOraIl/0Yr9eLxrRYNwNO/BCZrq9uVwv4i3cGWt64n8oA/t4sdy//1kAdx+HEhrts02Ydrd+HqViliRedcqZJsQJQDgCPYbY32zMnYaaT7f4TdNlhWUQxKjffcTqGAONUcarPBS7hHiOBrxDxUwnAQM7rM=
ARC-Authentication-Results: i=1; server2.sourceware.org
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1717059602; x=1717664402;
 h=content-transfer-encoding:in-reply-to:from:content-language
 :references:to:subject:user-agent:mime-version:date:message-id
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=tMvfmLdWOQKCpGVNyPVII3zRjx352A6NdRs944krOjQ=;
 b=fw3BstOoizqXa8kT7SwPE8+25MATgWRL0UpJ+obE2dTf5tOETUInfi99ivfBb/4cT7
 qC4rwJX4E5f4hK6e9ykk1xTyOizAX9a0jxK5cdlplg3QYmYaVP24BvGFqTy9XVB2IeE3
 EndqwWb1HEEbmIrz25Ee7IxILsa1WcbU3LjJ1A0QDuMd/JtRsv6+8Ih/z6MVAfd1+Ivq
 aOJJ6MtXiEyJw7fBT9R3vgytolm5zwHhdK4i4TwmofCCs08iJ+wH+Ra4wn3YerCuHY77
 gK8ba/WZXqObGF92lCGHvWs7taNVBA5ueSkIM0UIJgFXGnBTyn369Znsme2hfMGeucs4
 kCLw==
X-Forwarded-Encrypted: i=1;
 AJvYcCX87Zvj21YIR/0ImmwbUmb46zW7rELSOvLhCxMmIpnfPP58PuZjkUnCj3BRsiKL+ADwWnxCBFX8T2QWU/kIho6mqQ==
X-Gm-Message-State: AOJu0YxH3n3SkA0ixtJL6kUyupgniZwMNM0KvdEBtIRCFrw93rklAmLQ
 6tSLs4MqEHUYfbwFrHuK4On/RUokCS7xhhLK+lZ8vUyPbUgM9H35
X-Google-Smtp-Source: AGHT+IG+rx6NOTkJrlkBD1WbrIL/OXsurQk81IwmiZWqiC5b10FZtm+u6V4deXMsph2HjUi/CTCjjg==
X-Received: by 2002:a5d:58fa:0:b0:354:fb1a:25f5 with SMTP id
 ffacd0b85a97d-35dc00c9a4cmr1108247f8f.52.1717059602327; 
 Thu, 30 May 2024 02:00:02 -0700 (PDT)
Message-ID: <3eeb5e89-b225-4d68-b290-94dd3b9a3594@gmail.com>
Date: Thu, 30 May 2024 10:59:59 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PATCH v2] Cygwin: pthread: Fix a race issue introduced by the
 commit 2c5433e5da82
To: Bruno Haible <bruno@clisp.org>, Takashi Yano <takashi.yano@nifty.ne.jp>,
        cygwin@cygwin.com
References: <20240530050538.53724-1-takashi.yano@nifty.ne.jp>
 <0126a98a-3bdc-4303-a0d2-09f4c7009392@gmail.com> <1721092.SVj2RUA3Z2@nimes>
Content-Language: en-GB
In-Reply-To: <1721092.SVj2RUA3Z2@nimes>
X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_NUMSUBJECT,
 RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP,
 T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Noel Grandin via Cygwin <cygwin@cygwin.com>
Reply-To: Noel Grandin <noelgrandin@gmail.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 44U90Y6E2029181



On 5/30/2024 10:47 AM, Bruno Haible wrote:
> 
> SRW locks are spin-locks. Since they are only pointer-sized,
> ReleaseSRWLockExclusive cannot notify other threads — unlike CRITICAL_SECTION.
> Therefore, AcquireSRWLockExclusive must busy-loop when the lock is already
> held.
> 

No, they only spin briefly, before calling into the OS to sleep - see the article about their internals here:

https://learn.microsoft.com/en-us/archive/msdn-magazine/2012/november/windows-with-c-the-evolution-of-synchronization-in-windows-and-c#slim-readerwriter-lock


Alternatively, Windows already has an API for init-once i.e.
   https://learn.microsoft.com/en-us/windows/win32/sync/one-time-initialization

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

