From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 9 00:33:31 2009 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 460B110656C1 for ; Mon, 9 Mar 2009 00:33:31 +0000 (UTC) (envelope-from freebsd@jayloden.com) Received: from mail.jayloden.com (www.jayloden.com [66.150.227.71]) by mx1.freebsd.org (Postfix) with ESMTP id 231718FC0C for ; Mon, 9 Mar 2009 00:33:30 +0000 (UTC) (envelope-from freebsd@jayloden.com) Received: from [192.168.15.104] (c-98-221-217-95.hsd1.nj.comcast.net [98.221.217.95]) by mail.jayloden.com (Postfix) with ESMTP id 3F6D83160205 for ; Sun, 8 Mar 2009 20:33:30 -0400 (EDT) Message-ID: <49B463D7.9010401@jayloden.com> Date: Sun, 08 Mar 2009 20:33:27 -0400 From: Jay Loden User-Agent: Thunderbird 2.0.0.19 (Macintosh/20081209) MIME-Version: 1.0 To: freebsd-hackers@FreeBSD.ORG References: <200903082156.n28Lup7e085565@lurza.secnetix.de> In-Reply-To: <200903082156.n28Lup7e085565@lurza.secnetix.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Subject: Re: CPU user/kernel time given the PID 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: Mon, 09 Mar 2009 00:33:31 -0000 Oliver Fromme wrote: > ps(1) and top(1) both use ki_pctcpu, see the getpcpu() > function in src/bin/ps/print.c and format_next_process() > in src/usr.bin/top/machine.c Hi Oliver, thanks for the reply. I noticed the same after some digging through the source code for ps and top. While CPU usage % is a useful number also, I was hoping to be able to get CPU time(s). Possibly that information simply isn't available on FreeBSD like it is for other OSes. > As far as I know, there is no distinction between user- > mode and kernel-mode CPU time per process. It should > also be noted that the kernel's time cannot always be > attributed to a certain userland process. I would even > guess is that the majority of the CPU time spent in the > kernel is not on behalf of a specific userland process. I would suspect the same, but I did notice that times() does return separate values for user/system time on FreeBSD, so that implies that the system is able to differentiate between the two somehow. If you can get it from within the current running process the data must be there but I've no idea what interface (if any) exists to read that information for other processes. -Jay