From owner-freebsd-arch Tue Aug 15 21:41:20 2000 Delivered-To: freebsd-arch@freebsd.org Received: from alcanet.com.au (mail.alcanet.com.au [203.62.196.10]) by hub.freebsd.org (Postfix) with SMTP id 7FC0F37B74E for ; Tue, 15 Aug 2000 21:41:16 -0700 (PDT) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: by border.alcanet.com.au id <115253>; Wed, 16 Aug 2000 14:41:12 +1000 Content-return: prohibited Date: Wed, 16 Aug 2000 14:41:04 +1000 From: Peter Jeremy Subject: Re: would like to make cp_time a sysctl In-reply-to: <20000815205643.M4854@fw.wintelcom.net>; from bright@wintelcom.net on Tue, Aug 15, 2000 at 08:56:43PM -0700 To: Alfred Perlstein Cc: arch@FreeBSD.ORG Mail-followup-to: Alfred Perlstein , arch@FreeBSD.ORG Message-Id: <00Aug16.144112est.115253@border.alcanet.com.au> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline User-Agent: Mutt/1.2.4i References: <20000815205643.M4854@fw.wintelcom.net> Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 2000-Aug-15 20:56:43 -0700, Alfred Perlstein wrote: >I would like to have a sysctl that returns a string of the cpu states: >kern.cpustates.names: user nice sys intr idle >kern.cpustates.values: values I'd like a bit of clarification here. I presume you mean that kern.cpustates.names will return CTLTYPE_STRING with a value "user nice sys intr idle". Does the second line mean there will be a set of sysctls kern.cpustates.{user,nice,sys,intr,idle}, each returning a CTLTYPE_INT containing the relevant entry from cp_time[]? In this case, the kern.cpustates.names is not really necessary since a userland program can either search the namespace under kern.cpustates (see /usr/src/sbin/sysctl/sysctl.c:sysctl_all() for details) or just query the states in knows about (or wants information on). >I've been told that netbsd has thier own way of doing it, I don't >like it because they use SYSCTL_STRUCT which isn't very useful unless >you can include the C headers to parse it. There is lots of precedent for returning CTLTYPE_STRUCT in the FreeBSD kernel and I don't see any particular reason for not just copying what NetBSD have done. Why expend the extra effort of implementing the same functionality differently, just to be different? The other (slight) downsize is that your approach needs 5 system calls to return all the values, compared to one system call that returns 5 times as much data. My feeling is that your suggestion is slightly cleaner than using a CTLTYPE_STRUCT (though I'm not certain about kern.cpustates.names), but that is outweighed by the lack of compatibility with other implementations. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message