From nobody Sat Jul 25 11:06:31 2026 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4h6hrW1FWlz6mS24 for ; Sat, 25 Jul 2026 11:06:51 +0000 (UTC) (envelope-from dmarck@gmail.com) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h6hrV3yXhz3VgB for ; Sat, 25 Jul 2026 11:06:50 +0000 (UTC) (envelope-from dmarck@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5b29599b81cso1262273e87.1 for ; Sat, 25 Jul 2026 04:06:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784977609; x=1785582409; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yYJhrs3MC435osExuT77WIwyQ3Erys10q8HqeGwp4aQ=; b=PbohXdn5XlY2Gt/k4AqkVbJhi6pjtb2cqkqU6WD29qSTLPM1C9Dj5Dd839fghxUUHl l1eMt0n1DI9zJWwu3wJxsAFZTYn8yuFktEmajT5yr61fnIG4iflhnDzHM6GKXl2gzY0T 76Mi5bFk/bCSyeuXIHxXXHG70u0jmE2/JzeAHNzTB4BjUC+Vcs7jvyVl0lYDnNic9QDD f06kVE7zYbG/3gYeZQl4ifUR5hUXZ1nUq2ZXtr1PgIoE4tHPjQOIrQqMBcJ6uOxxQyIs QtvgXvZl8wYjUOZPivG820Hyc4wu/WwcIhTnnstc+Km9PKkdSDetOQTgQ1fH6YWwLmIB JMdw== X-Forwarded-Encrypted: i=1; AHgh+Rr//HAsZpDJ+kkFsT2jfvnpzSu+ucO11QLBf9niFYJYWFKnL0SXgrUhYYvnJsMWDEJmc0bE8fZWQKDUbCqgac0=@freebsd.org X-Gm-Message-State: AOJu0Ywi984VRodZIvkKiIs01yT/JF0Noeup/RBQerkOh2XXQRam2eWV TKVWNIcEPvL6yWCc5MQUeN6nBS/XGzlLUw0PKfDaWMhnAL8MroMhGOORh9IMF2mKgYNm5Q== X-Gm-Gg: AR+sD10ym9xS0BiMHC1N0X8L0RoVQGJ2Ntjo+meB0+u1Dud3MgJZIY6VZqwqRE7Fkwz Fd/iJiSuvZbDGF5ikyMZxr17NohA1u1ZnykRsTBbJnO6hcw2hZgKRHrYIEupQx9zuyhUhQPh0qp fmrW96+Zpoc2hmIkFPVed6FmF0RCmHVW23o48kcWp9SDqvO58RH9dFZX7wAZXEIl4RhzDLPYv78 pnUw4IMfy8pfWmTCcVkSLaUuqRijW04qkkkoQ/dS4b9BWSxNNxfXq0aaSap+HjAaox+n62p6DmB Hu+bA5phQaftwcowugW9I+rUvpWeYGCxbQ4N+OuosYyRtklKgk+wzuSq8z3UJsarODG4LL9jmBt GipNYFl/zvCd3bpDB3C8kr0lPC/mPZEtSmq7nfxaQ9c2tOrLwV67ftQEGWJdGTnZs9ad9cuaDHf D5f6IccHY4IF28Ij8+0nHUiu+XcC8= X-Received: by 2002:a05:6512:118d:b0:5b0:177f:beab with SMTP id 2adb3069b0e04-5b2c1b60d7amr302649e87.44.1784977608349; Sat, 25 Jul 2026 04:06:48 -0700 (PDT) Received: from [10.0.85.2] ([166.1.129.26]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b2be0777eesm394110e87.14.2026.07.25.04.06.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Jul 2026 04:06:47 -0700 (PDT) Message-ID: Date: Sat, 25 Jul 2026 14:06:31 +0300 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pthread_cond_wait spurious wakeup To: Konstantin Belousov , freebsd-hackers@freebsd.org References: <20260724230235.GB39748@zxy.spb.ru> Content-Language: en-US From: Dmitry Morozovsky In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4h6hrV3yXhz3VgB X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US] X-Spamd-Bar: ---- On 25.07.2026 2:41, Konstantin Belousov wrote: > On Sat, Jul 25, 2026 at 02:02:35AM +0300, Slawa Olhovchenkov wrote: >> Is pthread_cond_wait susceptible to spurious wakeup in FreeBSD? The >> pthread_cond_wait man page doesn't say anything about waiting thread >> can unblocking in cases like EINTR. But in >> lib/libthr/thread/thr_cond.c:232-249, >> I seem to see a successful return from pthread_cond_wait on EINTR >> case. So, we don't have a spurious wakeup issue, or does the man page >> need to be corrected and an additional predicate should be used in >> conjunction with pthread_cond_wait? > Spurious wakeups are allowed and can happen. They are not neccessarly > limited to signals delivery. > > 'The additional predicate' is how the user code must be structured anyway, > because pthread_cond_wait() drops the mutex that is supposed to protect > the data holding the condition. So, is the wording "The waiting thread unblocks only after..." from the manpage wrong (incomplete)? And, if yes, how do you think should it be rephrased/corrected? Thanks! -- Sincerely, D.Marck [MCK-RIPE] [ FreeBSD committer: marck@FreeBSD.org ] --------------------------------------------------------------------------- *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- woozle@woozle.net *** ---------------------------------------------------------------------------