From owner-freebsd-threads@FreeBSD.ORG Tue Oct 7 03:30:46 2008 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 BC9B8106568A for ; Tue, 7 Oct 2008 03:30:46 +0000 (UTC) (envelope-from davidxu@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 928DB8FC15; Tue, 7 Oct 2008 03:30:46 +0000 (UTC) (envelope-from davidxu@freebsd.org) Received: from apple.my.domain (root@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m973Uh9Y016872; Tue, 7 Oct 2008 03:30:45 GMT (envelope-from davidxu@freebsd.org) Message-ID: <48EAD851.7000404@freebsd.org> Date: Tue, 07 Oct 2008 11:32:33 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.9 (X11/20080612) MIME-Version: 1.0 To: Petri Helenius References: <48EA8320.5050500@helenius.fi> In-Reply-To: <48EA8320.5050500@helenius.fi> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: getrusage with pthreads 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: Tue, 07 Oct 2008 03:30:46 -0000 Petri Helenius wrote: > > Is there a way to get thread-specific CPU utilization like the getrusage > returns for the whole process? Looking at the kernel sources the > utilization is accumulated on thread basis and then summed up but it > would be useful to be able to determine utilization on a single thread > between two checkpoints. Would pmc or ITIMER_PROF help? > > Pete > You can use clock_gettime(CLOCK_THREAD_CPUTIME_ID), but I admit getrusage like function is better. Regards, David Xu