From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 17 02:21:35 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C22F1106564A for ; Thu, 17 Mar 2011 02:21:35 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 2FBE08FC0A for ; Thu, 17 Mar 2011 02:21:34 +0000 (UTC) Received: by wyf23 with SMTP id 23so2496052wyf.13 for ; Wed, 16 Mar 2011 19:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=b24KqvnzCJExZEUoM/fasCbkKId6Fkg1si3ONAGMfPs=; b=OvO3+Iudtfa+yimTcLOyVHHh8LGONdGZxtg5r0LvgppKQ8/W0Sd1QUNJwcpqFYExq3 FhcboQ361aeQIWlrv5Che78xQZ81CSOeJRfxIbkdBLSaET8T1U5+L5r0EoyUz9v91fVU XQvoa9WOyQXSoTLDZkQ5JFjY4zIgYAGrhx/lQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Wnoku/TFv5rjjqk3ArKc+8weczc5IzL/9WxUMT8YKGD1wTl2lKb33OqQYiuAN4UgeH VLYieTrRpx/q3ldv/PUJ71vT6n5XTBSw7n4v+Lub4gJzLw1I2SY7NX/69p7DUDXYr7vB /iGEiL2WG9M5CZe8gDsUfpzZKZUuF6aSlaEAY= MIME-Version: 1.0 Received: by 10.216.230.99 with SMTP id i77mr664626weq.100.1300328457639; Wed, 16 Mar 2011 19:20:57 -0700 (PDT) Received: by 10.216.173.142 with HTTP; Wed, 16 Mar 2011 19:20:57 -0700 (PDT) In-Reply-To: <4D8169BF.6090503@freebsd.org> References: <4D6ABA14.80208@rawbw.com> <4D6AC17A.7020505@rawbw.com> <4D6B01DB.9090909@freebsd.org> <4D80D5E0.5080302@rawbw.com> <4D8169BF.6090503@freebsd.org> Date: Wed, 16 Mar 2011 19:20:57 -0700 Message-ID: From: Garrett Cooper To: David Xu Content-Type: text/plain; charset=ISO-8859-1 Cc: Yuri , standards@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: Is pthread_cond_signal(3) man page correct? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2011 02:21:35 -0000 On Wed, Mar 16, 2011 at 6:54 PM, David Xu wrote: > On 2011/03/16 23:23, Yuri wrote: >> On 02/27/2011 18:00, David Xu wrote: >>> I think in normal case, pthread_cond_signal will wake up one thread, >>> but other events for example, UNIX signal and fork() may interrupt >>> a thread sleeping in kernel, and cause pthread_cond_wait to return >>> to userland, this is called spurious wakeup, and other events, I >>> can not think of yet, but I believe they exist. >>> >> >> Does this mean that pthread_cond_signal can also return EINTR? This >> isn't in pthread_cond_signal(3) either. >> > > No, it will return zero, returning EINTR is not allowed. Adding some more context by adding the appropriate POSIX spec material... RETURN VALUE If successful, the pthread_cond_broadcast() and pthread_cond_signal() functions shall return zero; otherwise, an error number shall be returned to indicate the error. ERRORS The pthread_cond_broadcast() and pthread_cond_signal() function may fail if: [EINVAL] The value cond does not refer to an initialized condition variable. These functions shall not return an error code of [EINTR]. So yes, EINTR not being allowed is by design and this backs up what davidxu@ is stating above. Our manpage just doesn't explicitly call this requirement out, unlike a Linux manpage I dug up and the OpenGroup manpage. >> Is this the case that all system calls should be assumed to be able to >> return EINTR or only those that have EINTR in their man pages? Thanks, -Garrett