From owner-freebsd-hackers@FreeBSD.ORG Sat May 21 13:03:13 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9FA7716A4CE for ; Sat, 21 May 2005 13:03:13 +0000 (GMT) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C3D843D77 for ; Sat, 21 May 2005 13:03:12 +0000 (GMT) (envelope-from keramida@freebsd.org) Received: from kane.otenet.gr (kane.otenet.gr [195.170.0.27]) by aiolos.otenet.gr (8.13.4/8.13.4/Debian-1) with ESMTP id j4LD3BK2021074; Sat, 21 May 2005 16:03:11 +0300 Received: from gothmog.gr (patr530-a216.otenet.gr [212.205.215.216]) by kane.otenet.gr (8.13.4/8.13.4/Debian-1) with ESMTP id j4LD1K3s024755; Sat, 21 May 2005 16:01:21 +0300 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.3/8.13.3) with ESMTP id j4LD39Pi042705; Sat, 21 May 2005 16:03:09 +0300 (EEST) (envelope-from keramida@freebsd.org) Received: (from giorgos@localhost) by gothmog.gr (8.13.3/8.13.3/Submit) id j4LD38fT042704; Sat, 21 May 2005 16:03:08 +0300 (EEST) (envelope-from keramida@freebsd.org) Date: Sat, 21 May 2005 16:03:08 +0300 (EEST) From: Giorgos Keramidas To: shiner chen In-Reply-To: <20050521104937.70622.qmail@web15509.mail.cnb.yahoo.com> Message-ID: <20050521160013.V18522@gothmog> References: <20050521104937.70622.qmail@web15509.mail.cnb.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Mailman-Approved-At: Sun, 22 May 2005 12:04:08 +0000 Cc: freebsd-hackers@freebsd.org Subject: Re: how to get the status of cpu in kernel? 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: Sat, 21 May 2005 13:03:13 -0000 On 2005-05-21 18:49, shiner chen wrote: > In order to implement a dispacthing policy I want to get the status of > cpu. I have read the code of top command and i find it get the status > of cpu by the function : > > int sysctlbyname(const char *, void *, size_t *, void *, size_t); > > I search the code of kernel ,then I consider that i can get the status > of cpu through the funciton: > > int kernel_sysctlbyname(struct thread *td, char *name, void *old, > size_t *oldlenp, void *new, size_t newlen, size_t *retval); > > I try to get the status of cpu by that function ,but it does not work! You're looking at the wrong place. There is a manpage for the sysctlbyname() function, which you obviously missed. > who can tell me the problem? Nobody until you show us the source, I guess :-) > How do i get the status of cpu? > How do i use it if the funcion is right? what's the mean of the > function's arguments ? Start by reading the manpage of sysctlbyname(). Then, if you still have problems, you can post the source online somewhere and point us people at the URL.