From owner-freebsd-ports@FreeBSD.ORG Fri Aug 20 13:05:58 2010 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA0F41065670 for ; Fri, 20 Aug 2010 13:05:58 +0000 (UTC) (envelope-from jessefrgsmith@yahoo.ca) Received: from n22.bullet.mail.mud.yahoo.com (n22.bullet.mail.mud.yahoo.com [68.142.206.161]) by mx1.freebsd.org (Postfix) with SMTP id 96C808FC1F for ; Fri, 20 Aug 2010 13:05:58 +0000 (UTC) Received: from [68.142.200.224] by n22.bullet.mail.mud.yahoo.com with NNFMP; 20 Aug 2010 13:05:58 -0000 Received: from [68.142.201.67] by t5.bullet.mud.yahoo.com with NNFMP; 20 Aug 2010 13:05:58 -0000 Received: from [127.0.0.1] by omp419.mail.mud.yahoo.com with NNFMP; 20 Aug 2010 13:05:46 -0000 X-Yahoo-Newman-Id: 309810.4365.bm@omp419.mail.mud.yahoo.com Received: (qmail 28108 invoked from network); 20 Aug 2010 13:05:46 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.ca; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Subject:From:To:In-Reply-To:References:Content-Type:Date:Message-ID:Mime-Version:X-Mailer:Content-Transfer-Encoding; b=aLGcXFp9M50Qu6p+ZBJAD0Kl7qS5JICXnrKs/cNfX2co/9/zxM6F36C465bBR3Df64tuanRXVYDBNfN8t+HCkj/F8qz5E3GoS+W5S6Dw8dw9adRS3ad/bJ/QqEuk2PoWDDkac3sfwdWQSCuqv7jyML1lPo4NHiiiUGh3dUoLEog= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.ca; s=s1024; t=1282309546; bh=T/D8P3jO5z8ie/wpMk+VzmlYPd9zJ+5kHp19SkDXn9U=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Subject:From:To:In-Reply-To:References:Content-Type:Date:Message-ID:Mime-Version:X-Mailer:Content-Transfer-Encoding; b=xj6dszPoXzbDo1uSKqsRXotmliNhHs8aps3p13FDGgDzsrj+ZkRX+Ob9qXdnbl6RK4865ZbrQ0FFur4po8sGyE5bnzI6PhbkhLkOQRFDEmxYC5AqT0lJkUIqRJWYGLu0f5sdiOK9Uk2Dn83sseN1Kh56VhvDQ3pUwegWkB8MWqc= Received: from [192.168.0.104] (jessefrgsmith@71.7.176.238 with plain) by smtp142.mail.mud.yahoo.com with SMTP; 20 Aug 2010 06:05:45 -0700 PDT X-Yahoo-SMTP: NPm1JouswBClX_uJxHJINmnKUpROdMKvLL0- X-YMail-OSG: TZKyLnAVM1nMeydHP16DB8Y_Oqrh32i2NVsG2nEyhE2htEV YKJQTLSbxrlKFCHq6Rnhemo419uldN76lBOZqpWTOsvpy.JOyLEgun3sgxWi CP3dU61VYMUK_6XX7kG4ooqs60QjZ70bWTbVqJyywOxxR_ggxutScAYTgrVh YCb60DOcfGfB1Qq7zk6XUaznXqNMKJwvuZUT11sslRgb3zVL9g7_9daQjgF1 xTncaoJl41TTmFbNFDGWzeUmfujX.CJ.tgVQP5nN0YaWm.kkkL5eOn0Eeln9 Mo0lcoP4obp4W24zVTXhUBVHFCEnpwQQA3FhhsJiTbR3YqHJFJ56gF3geFQ- - X-Yahoo-Newman-Property: ymail-3 From: Jesse Smith To: freebsd-ports In-Reply-To: <20100819192645.GA84660@icarus.home.lan> References: <1282245339.3094.24.camel@hp-laptop> <20100819192645.GA84660@icarus.home.lan> Content-Type: text/plain; charset="UTF-8" Date: Fri, 20 Aug 2010 10:05:37 -0300 Message-ID: <1282309537.2601.6.camel@hp-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 7bit Cc: Subject: Re: Converting from jiffies to ticks X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2010 13:05:59 -0000 -----Original Message----- From: Jeremy Chadwick To: Jesse Smith Cc: freebsd-ports Subject: Re: Converting from jiffies to ticks Date: Thu, 19 Aug 2010 12:26:45 -0700 On Thu, Aug 19, 2010 at 04:15:39PM -0300, Jesse Smith wrote: > I am currently trying to port a program from Linux to FreeBSD which > detects how much processor time a process is using. The native Linux > code does this (in part) by reading the number of "jiffies" a given > process uses. This info is pulled from the /proc/PID/stat file. > > One function is failing on FreeBSD and it's obviously because FreeBSD > does not have all the same files/data in the /proc directory. > > I've looked around and, as I understand it, FreeBSD uses "ticks" instead > of "jiffies" to measure process usage. However, how to gather that data > is a bit lost on me. > > This raises two questions for me: > 1. Where can I find the equivalent information on FreeBSD? I assume > there's a function call. Maybe in the kvm_* family? I need to be able to > get the number of ticks a given PID is using. > > 2. Any idea on what the conversion rate between ticks and jiffies is? > Are they the same thing, but with different names? Or is it a kilometres > and miles issue? > > > The rest of the program measures everything in "jiffies", so it would be > ideal for me to get the ticks used on FreeBSD (based on PID), convert it > to "jiffies" and pass it back to the main program. I would recommend you re-ask this question on freebsd-hackers. freebsd-ports isn't really for this purpose. Thanks Jeremy, I'll check out the freebsd-hackers list. Chuck, I read the manual entry for acct(2) and acct(5) and it's close to what I want. But the acct functions appear to just handle stats on processes that have terminated. I'm trying to get cpu usagbe while they're still alive. Appreciate the pointers, Jesse