From owner-freebsd-threads@FreeBSD.ORG Fri Jul 13 21:05:49 2012 Return-Path: Delivered-To: freebsd-threads@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 103FC106564A; Fri, 13 Jul 2012 21:05:49 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 9CADF8FC08; Fri, 13 Jul 2012 21:05:48 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id B91963592D9; Fri, 13 Jul 2012 23:05:47 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 91E6D2847B; Fri, 13 Jul 2012 23:05:47 +0200 (CEST) Date: Fri, 13 Jul 2012 23:05:47 +0200 From: Jilles Tjoelker To: David Xu Message-ID: <20120713210547.GA67646@stack.nl> References: <201207120800.q6C80ISC073892@freefall.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201207120800.q6C80ISC073892@freefall.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-threads@FreeBSD.org Subject: Re: threads/168417: pthread_getcpuclockid() does not work to specification X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 21:05:49 -0000 On Thu, Jul 12, 2012 at 08:00:18AM +0000, David Xu wrote: > The following reply was made to PR threads/168417; it has been noted > by GNATS. > From: David Xu > To: bug-followup@freebsd.org, chris.hall@highwayman.com > Cc: > Subject: Re: threads/168417: pthread_getcpuclockid() does not work to specification > Date: Thu, 12 Jul 2012 15:51:02 +0800 > I have worked out a patch trying to fix the problem: > http://people.freebsd.org/~davidxu/patch/cputime_clockid.diff Some comments: * Should clock_getcpuclockid() and clock_getthreadcpuclockid() be syscalls or can the 2**31 reserved clock ids be hard-coded into libc just like the other clock ids are? * Perhaps clock_getcpuclockid() should check if the pid is valid. * I think p_canwait() is not the right permission check. The p_canwait() check is for wait4() and takes into account that denying at that point completely breaks the process's tracking of its child processes. The right permission check is probably p_cansee() because that's what the kern.proc.* sysctls that return CPU time also check. The recently added pget() function can perform pfind() and p_cansee() in one call. * Why can a thread's CPU clock only be read from the same process? The kern.proc.* sysctls allow querying any thread whose process you p_cansee. However, the POSIX APIs only allow accessing threads within the process because there is no pthread_t for other threads. -- Jilles Tjoelker