From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 3 21:37:02 2008 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 2FADC1065686 for ; Thu, 3 Jul 2008 21:37:02 +0000 (UTC) (envelope-from babkin@verizon.net) Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) by mx1.freebsd.org (Postfix) with ESMTP id 1C99D8FC17 for ; Thu, 3 Jul 2008 21:37:02 +0000 (UTC) (envelope-from babkin@verizon.net) Received: from vms126.mailsrvcs.net ([172.18.12.131]) by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0K3G0019K9DF9YQ3@vms042.mailsrvcs.net> for freebsd-hackers@freebsd.org; Thu, 03 Jul 2008 16:36:51 -0500 (CDT) Received: from 65.242.108.162 ([65.242.108.162]) by vms126.mailsrvcs.net (Verizon Webmail) with HTTP; Thu, 03 Jul 2008 16:36:51 -0500 (CDT) Date: Thu, 03 Jul 2008 16:36:51 -0500 (CDT) From: Sergey Babkin X-Originating-IP: [65.242.108.162] To: freebsd-hackers@freebsd.org, Stephen Montgomery-Smith Message-id: <26495768.1230901215121011453.JavaMail.root@vms126.mailsrvcs.net> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7bit X-Mailman-Approved-At: Thu, 03 Jul 2008 23:29:17 +0000 Cc: Subject: Re: time used by a thread 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, 03 Jul 2008 21:37:02 -0000 >I want to use getrusage to see how much time a program is using. But >this is a multithreaded program, and I just want the time taken by that >particular thread! > >I know this info must be available somewhere, because top -H seems to >provide it. But getrusage seems to give the total rusage for the whole >program, not just the thread. > >Any ideas? I would especially appreciate a portable solution that works >for OS other than FreeBSD (e.g. linux, etc as well). On Linux and Solaris it can be done by reading the /proc filesystem. Probably on FreeBSD too, haven't tried. But it's different on each OS. -SB