libgtop"> table ()"> ]> The &table; system call under Linux Martin Baulig
martin@home-of-linux.org
1998 Martin Baulig This documentation is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more details see the file COPYING in the source distribution of LibGTop. $Id$ Under Linux, reading from /proc is somehow slow because the data needs to be converted into a stringified representation from the kernel and to be parsed from the application program to get the original data back. While doing the DEC OSF/1 port of &libgtop; I got the idea to add something similar to the &table; function there to the Linux kernel. This is what this document is about.
Why not <function>sysctl</function>? Some weeks ago, I posted the initial proposal of the project to &news-c-o-l-d-s; with Message-ID <of7zpfprs08.fsf@Taurus.uni-trier.de>. You can also read this article at my site: &table-announce-first; Some people told me to include all the stuff into sysctl instead of inventing a new system call. Basically this is a good idea, but the main problem with sysctl is that this should be applied to standard kernels and not just as a short patch. Well, AFAIK something similar is on the "wish list" for 2.2er kernels - but of cause it'll need some time until we have a real replacement of the /proc filesystem in sysctl. If someone thinks that this absolutely should be included in sysctl: think about some kind of interface, discuss it with the kernel developers, ... About the &table; function Using the &table; function will not affect any existing kernel structures and can be done independent from kernel development. So it can easily be used in &libgtop; until we have something simliar in standard kernels. If you want to use the &table; function in your own programs, be aware that it is just intended to be some kind of quick solution for &libgtop; until there's something better in standard kernels. How to use the &table; function in &libgtop; The source code of the &table; function is distributed together with &libgtop;. It can be found in the kernel/table20 directory for 2.0.xx kernels and in the kernel/table21 directory for 2.1.xx kernels. You can also download it from my site: &table20-tgz (for kernel 2.0.xx) &table21-tgz (for kernel 2.1.xx) Copy the contents of the appropriate directory to /usr/src/linux/table, apply the patch to the kernel and re-configure &libgtop;. After that, you can unmount /proc and &libgtop; will still work ! Maybe one could consider this as a bug, but currently there isn't a configuration option to disable the &table; function once you applied the patch ... Currently I'm working on the 2.1.x version to implement some features newer kernels have - so the 2.0.x version may not have all features the 2.1.x one has. The 2.1.x version of the &table; function is implemented as a kernel module. You have to do a insmod table/module.o manually to use it. This has the advantage that you don't need to reboot if you want to play around with the code a little bit.