DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 44U9FeAC2034102 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=jnyrs0Fz X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39EF5385E45D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1717060540; bh=k8mJJshwIAJOxpENGCfoweTg2xqkf0+KknEaxjaTC4s=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=jnyrs0Fz7mu9UQjOi/YoF66L2Pp6qhv3oWL2p4FyBTvzCvNV1gSSl4wYGG6XjNbWI pf3q/F5wPOgUerlbl20u9hPF0giPnMi5tS8VAO+xsNpOcj7pKXgflzo1evbndgyFr3 RCGVE0HNKkd3AbMVTe2f/QE2FzvTVeAHi7q1hRZM= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 549203858D20 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 549203858D20 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1717060521; cv=pass; b=lzDGVXKVWroGY5UfofhySla8zhsaUyF6BMbyvdltr9+WTnwXYCqWsjtlrWTO8J1O80nmJ31hVaOWbJxw2eJpPTtvZeDP9gaeZq0Z8v9OPZ6mrq4xOevO/mSD/X/avRtHu/KSJFklEKFd1UdocdDU/DBGWSeTjy3zLno+18wfyOU= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1717060521; c=relaxed/simple; bh=HyqxtqgYr0pfjHt6PIzL8FvBub2UcuaYyeLYOmPRsZY=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=fnBTAGqtek0JQk4fWjunYbPwYX9fK5nBH7ip9orXPH9Ld984rJRAiJnm0Xx33xiG5A0yvQlfZfXEGxDF3M70xcIwhhb01/gYjIR1wFCbUGeOvK3E9q4VUqBAM8Zfa4azhpp/MVb+pcIkpvPqWi2VVkGh5K2y20Dqagp8sA+Y9pY= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1717060516; cv=none; d=strato.com; s=strato-dkim-0002; b=qNBG2+cwdoUZF2Aq3SUUEezovgePwmDYAxm/xVzTkKG6Wn+PR3J62ZaDoIDPwsrfHF L14Jefrq1zuIhQOLWNq0PnNGZSNyaRlr2I9a1wEb6vCAbnsDq+fTVLLqPLJkJGwml7VL P/hpYKrEOiXGj7g+rCDTjjzgxrh6YBVhnwuigbfW3YuKedQFxWM/1y8KcLjk5UeLSVCL AtsS2BQPQMBA0nuRtopuargIcDDo0znXPhEofGago4DkhpuJ0kyAt4J0XdY+/EC3ZCk+ iBH0VQLgT13BcBwzPaGLhBmIeLtb+RIfx38GPB7YE+yimpNpU8ShFxZZB5IQmdY8KzD8 a84Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1717060516; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:To:From:Cc:Date:From: Subject:Sender; bh=+suRN52Lgx66kUCVTx3ASCjXxwfF5woD3RK1nekHLMk=; b=c8VFM1c4gd5c7Ct2q1tFkWL/VnUWonI3v0IqS8lN1xrd2D7wJLodj3Gu6QnhyRAsN4 IdeWqn9LdZ0+EkUWcCQKMYW925on+mPMHr5XkfKXWQjFmFD/dPm7Q+KXge2FsfS50YVw zvgoXJ/ylzSKQEJWRrOEAQXGVQF8XsncDaT08XGhb1usPXlA2hWZUQ2LdMNlc5mcstpl Y85QgedBrio6BRO54B5KogyurUSUhKtay3quxcPYWU370vB9n141CoDTMtYW+NsxNz8Y XNxmD0bxqNvK/we+76q5DE0AB8HkH9kjGQlXyzUVno/aS5g6MJ4obiLU8yk7ztu9jbB8 nJwA== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo01 X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpOfjqSRCBA3DxwVMPzYVsfrcNDf" To: Takashi Yano , cygwin AT cygwin DOT com, Noel Grandin Subject: Re: [PATCH v2] Cygwin: pthread: Fix a race issue introduced by the commit 2c5433e5da82 Date: Thu, 30 May 2024 11:15:15 +0200 Message-ID: <2073558.3YGTXZJOeS@nimes> In-Reply-To: <3eeb5e89-b225-4d68-b290-94dd3b9a3594@gmail.com> References: <20240530050538 DOT 53724-1-takashi DOT yano AT nifty DOT ne DOT jp> <1721092 DOT SVj2RUA3Z2 AT nimes> <3eeb5e89-b225-4d68-b290-94dd3b9a3594 AT gmail DOT com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, 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 AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Bruno Haible via Cygwin Reply-To: Bruno Haible Content-Type: text/plain; charset="utf-8" Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 44U9FeAC2034102 Noel Grandin 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 Still: Does ReleaseSRWLockExclusive notify other threads? > Alternatively, Windows already has an API for init-once i.e. > https://learn.microsoft.com/en-us/windows/win32/sync/one-time-initialization 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; } ? Bruno -- 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