Skip site navigation (1)Skip section navigation (2)
Date:       Wed, 16 Aug 2000 14:41:04 +1000
From:      Peter Jeremy <peter.jeremy@alcatel.com.au>
To:        Alfred Perlstein <bright@wintelcom.net>
Cc:        arch@FreeBSD.ORG
Subject:   Re: would like to make cp_time a sysctl
Message-ID:  <00Aug16.144112est.115253@border.alcanet.com.au>
In-Reply-To: <20000815205643.M4854@fw.wintelcom.net>; from bright@wintelcom.net on Tue, Aug 15, 2000 at 08:56:43PM -0700
References:  <20000815205643.M4854@fw.wintelcom.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

Peter



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?00Aug16.144112est.115253>