Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Aug 2000 02:46:47 -0700
From:      Peter Wemm <peter@netplex.com.au>
To:        Peter Jeremy <peter.jeremy@alcatel.com.au>
Cc:        Alfred Perlstein <bright@wintelcom.net>, arch@FreeBSD.ORG
Subject:   Re: would like to make cp_time a sysctl 
Message-ID:  <200008160946.CAA44281@netplex.com.au>
In-Reply-To: <00Aug16.144112est.115253@border.alcanet.com.au> 

next in thread | previous in thread | raw e-mail | index | archive | help
Peter Jeremy wrote:
> On 2000-Aug-15 20:56:43 -0700, Alfred Perlstein <bright@wintelcom.net> 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.

On FreeBSD right now, we have a few structs:

kern.clockrate: { hz = 100, tick = 10000, tickadj = 5, profhz = 1024, stathz = 128 }
kern.boottime: { sec = 966386120, usec = 228217 } Tue Aug 15 17:35:20 2000
vm.loadavg: { 0.48 0.61 1.11 }
machdep.consdev: { major = 12, minor = 255 }

Since it is one sysctl vs five, and doing name2oid translation requires an
*extra* syscall, I'd suggest NOT using OID_AUTO, and using a single struct
and define the format strings for sysctl to "present" it to the user...

> Peter

Cheers,
-Peter
--
Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au
"All of this is for nothing if we don't go to the stars" - JMS/B5



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200008160946.CAA44281>