DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 44UATIps2058175
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=coDU+Qk0
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2B47385E833
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1717064957;
	bh=CngAcV55qcTfHQViXF34A8Xa0C4accgIq96+6kXr5gM=;
	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=coDU+Qk0LOwBk12KWYt8WBPlXbLgSELEgH4wYD4sl0baxwFlfLjdQ8kas5J6ImmFS
	 54pGS+Qf5T4Hjo463+qHaye7jjo/KA47EXrC4T0a/ZeLnE6TbOGGAwJ7n3Dp46BDgp
	 eeql4lWhK49p2rQfltF5bGjJtW+rjNiszlQ7BMbk=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 063333858C50
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 063333858C50
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717064904; cv=none;
 b=B0Wg/wB3TrA+xonhrz4xBj1HngkrEce3mRXEA2ZvOWjLxl4tM8wqyjns8m4g+l0VQ2tuYsb2/fVSoJm35haZR1QOkYNFp4PLnKXchKVueGO9iMa0LeyHEd5BNP5/eJaAKmjLLpIj9rEvCFnUA99J5+SqYMsOFN6880mi9lFhbnA=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1717064904; c=relaxed/simple;
 bh=uORZJ/TXZeS4ch+bt9BzUAqHn1D0SIqIOwxafr84sCE=;
 h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;
 b=lq9Taig9iuygy3NwRhwok4jPkrBCCuwDCYRTL4k3vAO1KtnSxDwpcAZF+V3gJ3lkzmhvF3ZYVg+cmbfxy3FSCaOrGFS2YeLK7uw3xHXgISKhrJTKvijZqIPz83WfQ2qPNCjESm1tbNO456Uk3Pg2SszeVO5w8ddNyt0Q4Rhd0iQ=
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=1717064901; x=1717669701;
 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=GKBVrTz1BlVJOvBORcMWPN7i5yyn8/VWAgY8MQHkvFw=;
 b=AhCiYuaygJPh1qy5hd20oDw9eewP1xfMwi1qnFimPixNDdDOeBLq/STTQBiYs4igXq
 otd+wZh9Wx4kCSdTdJtVPS+PhrvsdLADdqOB3kXT9HEuuQpnMMcqdy8N/PD8KtZ5TRTH
 VzsmuDDj64RXD2WQEUVzUEhJzsnyxF85m8jYNJtR/hp+LWN9y94kir/mELS5m11neEc0
 t4POppX5/cCstnpV5bjjp47np5JeFPRhD+VlfJxEOkPHvASVZzn2FvypKux1hKcQVJ2F
 RU1TQXpg3Z2fTikpM8QNIKtaaKU3S+KThj+znq4vRYfPMu5Kr/vWSCo3sOyHQVlpxDnZ
 o9FA==
X-Forwarded-Encrypted: i=1;
 AJvYcCVM76SJjbvFYL0yCyoPV9mYVmAw8+D2QEMOFlCeAwEoMsFqHEF/LM6jTbMQtMZrs+BPYoaKcvcDGkU3Vt43C4p8SQ==
X-Gm-Message-State: AOJu0Ywn4+YYmxGpY7hbaiRLL9TFfQp4ef+QWJDZg0LnQDtTiwJSlZWP
 /deQLsJ0YAIu90nYV2zlKJuwuZ6vqCmRVelSgHghjHr/pFJl/W1h
X-Google-Smtp-Source: AGHT+IGPAitwXEFYwu5Pugo8vp2ae2Pw/A212kngfMHgYBfEVXUHIGgb1xXdUqSTIWwQgZyYNbvx6w==
X-Received: by 2002:a05:600c:3506:b0:418:ee30:3f92 with SMTP id
 5b1f17b1804b1-421279243ebmr19333375e9.25.1717064900408; 
 Thu, 30 May 2024 03:28:20 -0700 (PDT)
Message-ID: <233f8671-c1af-4587-bb83-a206a7e90090@gmail.com>
Date: Thu, 30 May 2024 12:28:16 +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>
 <1721092.SVj2RUA3Z2@nimes> <3eeb5e89-b225-4d68-b290-94dd3b9a3594@gmail.com>
 <2073558.3YGTXZJOeS@nimes>
Content-Language: en-GB
In-Reply-To: <2073558.3YGTXZJOeS@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-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>



On 5/30/2024 11:15 AM, Bruno Haible wrote:
> 
> Still: Does ReleaseSRWLockExclusive notify other threads?
> 

Of course? How else would a lock work, it must release other waiters?

It might not be a fair lock though, which is not a problem for this situation, which does not require fair locking.


> Functionally, the INIT_ONCE looks interesting. But, like Takashi Yano mentioned,
> how would you make it fit into a pthread_once_t that is defined as
>    struct { pthread_mutex_t mutex; int state; }
> ?

Something like:

struct once {
    union {
       pthread_mutex_t old_mutex_field_for_size_compatibility;
       SRWLOCK lock = SRWLOCK_INIT;
     };
     int state;
};

Regards, Noel Grandin

-- 
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
