From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 20 13:28:41 2010 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 9A2681065674 for ; Fri, 20 Aug 2010 13:28:41 +0000 (UTC) (envelope-from jessefrgsmith@yahoo.ca) Received: from n18.bullet.mail.mud.yahoo.com (n18.bullet.mail.mud.yahoo.com [68.142.206.145]) by mx1.freebsd.org (Postfix) with SMTP id 4E05B8FC18 for ; Fri, 20 Aug 2010 13:28:41 +0000 (UTC) Received: from [68.142.200.221] by n18.bullet.mail.mud.yahoo.com with NNFMP; 20 Aug 2010 13:15:48 -0000 Received: from [68.142.201.249] by t9.bullet.mud.yahoo.com with NNFMP; 20 Aug 2010 13:15:48 -0000 Received: from [127.0.0.1] by omp410.mail.mud.yahoo.com with NNFMP; 20 Aug 2010 13:14:32 -0000 X-Yahoo-Newman-Id: 219642.23300.bm@omp410.mail.mud.yahoo.com Received: (qmail 85682 invoked from network); 20 Aug 2010 13:14:31 -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:Content-Type:Date:Message-ID:Mime-Version:X-Mailer:Content-Transfer-Encoding; b=VZGlIWjvdNPu3ZAlb+9YRuC0uTxsgWyWBMju47UNVfsIrnL5UwgcXpmwDTXXHFAvKesVF7s6d6PncDfjti6vBvMo6xXwjZp8rOTAH0HJWDQj/XSMdO6JEsih/zI0ktBGKgBxbCrfBVrELrRxLL5TQ6+6sie3g3ResRDCxnZxyhE= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.ca; s=s1024; t=1282310071; bh=3zWM+lhz5N/uqHQYBq1s22rx1Ye7sHY1DUZ5e6qPOFM=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Subject:From:To:Content-Type:Date:Message-ID:Mime-Version:X-Mailer:Content-Transfer-Encoding; b=KyCTbjC0Jnwl9fEbQyorz1P1t5v++yEDCTZCGJ3RiuIK5quuHcgWxenhBu3ZIGC+gweTwQ1o/fFumdvNJU1z37oXbModu0BVZEtgPO7chc1XTkd+b9k5D4JTTMZ3qtPVCDpIPdwYf7ul4JraJ20Du02ZGx2nChC7H8xPovvfRzk= Received: from [192.168.0.104] (jessefrgsmith@71.7.176.238 with plain) by smtp143.mail.mud.yahoo.com with SMTP; 20 Aug 2010 06:14:31 -0700 PDT X-Yahoo-SMTP: NPm1JouswBClX_uJxHJINmnKUpROdMKvLL0- X-YMail-OSG: SgBPXqYVM1ne_z0Gmdw4owAURGukv0DaTfc0vrNVJdbslPr hjykkBbRsDhNZ2pXl4xK8aUg3Iq.L59kQ0EJlsrXWHOIKfH4LoTODY6B6OPY 9OxDL2CRmzyZMyWlaJOEbJAwlMKvD4CBp.2YSuwV3aIHONxGwPxwKRIF6PRy cnIBra.SFtDhyrVDy.tEX.eD.Eri0RmWiuoXmI7E5qvcZHxKw9k46lU.7.Sb phHe8QWL_8oAC6Ph5Q_52BCwz6J5vw9t16VZgsqcwPrRQAO2a1a1QN6Vz0iU QDZIiSSFzyH5DrrzEO3vL.HI- X-Yahoo-Newman-Property: ymail-3 From: Jesse Smith To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" Date: Fri, 20 Aug 2010 10:14:23 -0300 Message-ID: <1282310063.2601.9.camel@hp-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 7bit Subject: Converting from jiffies to ticks 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: Fri, 20 Aug 2010 13:28:41 -0000 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 a question for me: 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, both in the kernel and userspace. 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. Thanks for any advice, Jesse