source: trunk/third/libgtop/doc/white-paper.texi @ 18272

Revision 18272, 3.8 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18271, which included commits to RCS files with non-trunk default branches.
Line 
1@node White Paper, Reference Manual, About, Top
2@chapter LibGTop White Paper
3
4@menu
5* Introduction::                Introduction
6* Overview::                    Overview
7@end menu
8
9@node Introduction, Overview, White Paper, White Paper
10@section Introduction
11
12Many modern UNIX systems like Solaris, BSD or Digitial Unix only allow
13priviledged processes to read information like CPU and Memory Usage or
14information about running processes.
15
16@itemize @bullet
17@item
18BSD, for instance, doesn't have any other way to get those data than reading
19directly from @file{/dev/kmem} and you need to be in the @code{kmem} group to
20be able to read this.
21
22@item
23Other systems, like Digital Unix, allow all users to get things like CPU and
24Memory statistics, but only root may read information about any process other
25than the current one (you may not even get information about your own processes
26if you're not root).
27
28@item
29Linux has a very nice @file{/proc} filesystem, but reading and parsing
30@file{/proc} is very slow and inefficient.
31
32@item
33Solaris is a bit better, but you still need to be in the @code{sys} group or
34even root to get some data.
35@end itemize
36
37Because of this system utilities like @code{ps}, @code{uptime} or @code{top}
38often are setgid kmem or setuid root. Usually, they're also very specific to
39the system they're written for and not easily portable to other systems without
40a lot of work.
41
42This, of cause, becomes a problem for graphical tools like @code{gtop} - making
43a GTK+ program setgid or even setuid would be a security hole as big as you can
44drive the entire X11 source code through. For the GNOME project, we also needed
45some kind of library which provides all the required information in a portable
46since there's more than just one single program that wants to use them - for
47instance @code{gtop} and the @code{multiload}, @code{cpumemusage} and
48@code{netload} panel applets.
49
50@node Overview,  , Introduction, White Paper
51@section Overview
52
53This section should give you a short overview on how LibGTop was developed, which
54things needed to be considered and how it works.
55
56@menu
57* Interface Design::            Things that need to be considered
58* Server Implementation::       The LibGTop "server"
59@end menu
60
61@node Interface Design, Server Implementation, Overview, Overview
62@subsection Interface Design
63
64At the very beginning, it was necessary to collect all the data the library part
65should provide and put them into some C structures. This was not that easiy as it
66might sound since LibGTop should be portable to any modern UNIX system with a common
67library part on all those systems, but the data that should be returned vary from
68system to system. For instance some systems support shared memory, but some others
69may not.
70
71The header files where we define these C structures (which are system-independent) are
72shared between client and server. This way we can call the system dependent code
73directly where we do not need any special privileges to do so.
74
75All of those structures contain a @code{flags} member which is interpreted as a bit
76mask and tells the caller of the library functions which of the fields in the returned
77structure are valid and which are not.
78
79@node Server Implementation,  , Interface Design, Overview
80@subsection Server Implementation
81
82The LibGTop @dfn{server} is a setgid/setuid binary which contains all the system
83dependent code which needs special privileges. It is only build if it's required
84on the current system (for instance, the Linux kernel provides all the required
85data via its @file{/proc} filesystem so we do not need the server at all) and it
86only contains the @dfn{features} which need privileges.
87
88Whenever we do not need any privileges to get all the data for some of the requested
89structures (here called @dfn{features}) the library calls the sysdeps code directly
90rather than using the server.
Note: See TracBrowser for help on using the repository browser.