On 11/07/06, Weldon Goree <[EMAIL PROTECTED]> wrote:
According to the source, `/sbin/sysctl hw.sensors` calls its own main
parsing routine 256 times to check each of the 256 possible sensors and
allocates its own list from the results. Eek. Since I'm just writing a

Yes, I thought the same thing the first time I encountered it.

Plus you have to remember the fact that sysctl(3) has to go through
the whole linked list once again to find the last sensor even if you
call it in strictly increasing order, and it also has to go through
the whole linked list to conclude about the non-existence of a sensor.

If I remember my Analysis of Algorithms class correctly, this might
mean that the complexity of the sysctl(3) approach in populating a
userspace array with sensors is about n*m if n goes to infinity for m
less than or equal to n, where n is the maximum possible number of
sensors, and m is the actual number of elements in the sensors linked
list.

But the thing is, n could not go to infinity because it's a constant
that stays at 256, and m usually varies in around 12 to 64, so at the
end of the day, it doesn't make sysctl(3)/sysctl(8) any noticeably
slower, does it? :)

voltage monitor I suppose I could have it do that once on init and then
just monitor the specific sensors it finds relevant, assuming I can
convince myself that the numbers are assigned once at bootup (or at
least do not change once assigned).

Yes, they do not change once assigned. Take a look at
usr.sbin/sensorsd, if you haven't already.

Reply via email to