CS 502 Operating Systems WPI,
Fall 2006
Hugh C. Lauer Project
4 (30 points)
Assigned: Monday, November 13, 2006 Due:
Monday, December 4, 2006
This is an investigative project, not an explicit programming project. Using your virtual machine, the source code of your kernel, and any other resources, investigate and report on two of the following three issues, each of which is explained in more detail below:–
1. Listing
processes in /proc.
2. Network failure after installing a new kernel on a VMware virtual machine.
3. Open
questions with respect to getrusage()
and printk().
To carry out your project, you may use a combination of
reading and analyzing kernel code, experimenting with it by embedding printk statements, or by setting
breakpoints with kdb.
Each topic is worth 15 project points. Write a short report on each of your two chosen topics — e.g., about 1-3 pages plus any output results from your experiments. A patch file is not necessary unless you think it will help your analysis or bolster your report.
Please submit your project using the web-based turnin facility at
http://turnin.cs.wpi.edu:8088/servlets/turnin/turnin.ss
For purposes of turnin, this assignment is project4.
1. Listing processes in /procIn Linux, you can access many values internal to the
kernel via the /proc file
system. Originally designed to allow easy access to information about processes
(hence its name), it is now used by every part of the kernel which has something
interesting to report. For example, if you list /proc/modules, you see a list of modules; similarly,
listing /proc/meminfo reports
memory usage statistics. The directory structure and files under /proc are not “real” in the sense that
they represent persistent data on disk. Rather, they are generated dynamically by
the operating system each time they are accessed.
If you list the directory /proc, you will get something like the following:–

Each number in the left columns of the listing is a
process ID — i.e., a pid —
and each entry corresponds to a directory containing useful information about
the corresponding task. Ostensibly, every task or process in the circular list
of task_struct structures
should be listed in /proc.
The item self in the right column
is a soft link pointing to the task directory for the current process (i.e.,
the one executing ls). Listing
/proc/self produces
something like the following:–

The ps
and top commands get their
information on currently running processes from /proc entries. Specifically, they look at the stat, statm
and status files in each /proc/<pid> directory.
The source code for the /proc
file system is located in fs/proc/
of your kernel source tree. In particular, the file root.c provides information on the “files”
and directories that appear at the root of the proc file system (/proc). In earlier versions of Linux, root.c included a function called get_pid_list() that enumerated the
processes or tasks. However, it seems that Linux kernel 2.6 does not include such
a function.
For this project, discover and report how the list of
processes is generated. That is, show what functions are invoked, when are they
invoked, and what data structures are set up so that a listing of the /proc directory includes an entry for every
process. Your report should show the flow of data and/or control in such a way
that some else could understand it with a view to modifying it. (Robert Love’s book, Linux Kernel Development, is an example
of the appropriate level of detail.)
Both the instructor and some students have experienced network problems after installing new kernels in their VMware virtual machines. That is, the network connection simply stops working, and it becomes impossible to move data to or from the virtual machine.
These problems might have to do with the VMware Tools that were installed in the virtual machines before they were distributed to the class. VMware Tools are an important part of the creation of the virtual machine, partly because they provide a display driver capable of supporting graphical user interfaces with more than 16 colors. In addition, they provide access to the mouse (for virtual machines running on VMware server) and drivers for other devices such as the virtual Ethernet card.
This is a possible explanation of the network failures. When building and installing a new kernel in the guest operating system, the standard SUSE driver for the network card would be rebuilt and re-installed, overwriting the VMware driver and somehow causing it lose network contact with the VMware system running on the host operating system.
In the virtual machines for both the Pentium (i386) and
Opteron (x86_64) architectures, the VMware
Tools package can be found as a file in the directory /tmp with the extension .rpm. This package was installed using
the command
rpm –Uhv /tmp/{VMware tools file}.rpm
Among other things, the package installed a PERL script that was executed prior to cloning the virtual machine for distribution, namely
/usr/bin/vmware-config-tools.pl
For this project, analyze this PERL script (and possibly the .rpm file) to determine what it does to the network interface. Also, analyze the network configuration information in /etc/sysconfig to determine why network access fails after the installation of a new kernel. If possible, recommend a solution or workaround to the problem of network failure. Also, if possible, test your solution.
Note that this part of the project is probably irrelevant to students using Macintosh Parallels. If you are a Parallels user and want to pursue this topic, please use either a virtual machine on csopt4 or a Pentium virtual machine on VMware Player.
The function getrusage returns a data structure defined by
struct rusage {
struct timeval ru_utime; /* user time
used */
struct timeval ru_stime; /* system time
used */
long
ru_maxrss; /* maximum
resident set size */
long
ru_ixrss; /* integral
shared memory size */
long
ru_idrss; /* integral
unshared data size */
long
ru_isrss; /* integral
unshared stack size */
long
ru_minflt; /* page reclaims
*/
long
ru_majflt; /* page faults
*/
long
ru_nswap; /* swaps */
long
ru_inblock; /* block input
operations */
long
ru_oublock; /* block output
operations */
long
ru_msgsnd; /* messages sent
*/
long
ru_msgrcv; /* messages
received */
long
ru_nsignals; /* signals
received */
long
ru_nvcsw; /* voluntary
context switches */
long
ru_nivcsw; /* involuntary
context switches */
};
The Linux man page for the getrusage says that “only the fields ru_utime, ru_stime, ru_minflt, ru_majflt, and ru_nswap are maintained” by Linux versions 2.4 and 2.6. Examine the kernel code that populates this data structure to determine if this statement is correct.
In particular, Project 1 of this course asked you to develop a doit command that reports, among other things, the number of voluntary and involuntary context switches. These values are in the fields ru_nvcsw and ru_nivcsw, which are not listed in the man page as being maintained by Linux. Determine whether these fields are valid or not. If not, determine whether there is any data structure or function that could fill in these fields.
In Project 2 of this course, a number of students reported that the printk function did not act like the semantics of printf, in the sense that the second and subsequent arguments should be substituted for the “%” fields in the string of the first argument. A brief examination of the kernel, however, reveals a number of places where printk is used with two or more arguments in the expectation that it works like printf, and the implementation of printk in kernel/printk.c suggests that it should work.
Determine why printk does not work as expected and what, if anything, can be done about it. Your report for this part of the project should include a discussion of both getrusage and printk.
You may collaborate with other students in this class, and you may contact other experts for this project. However, your report must be written by you alone, in your own words.
Your submission should include
1. The written report for each of the two topics that you have chosen. The preferred format is Microsoft Word (i.e., .doc).
2. Any test program and output to support your report (if submitting a program, please include a makefile).
Be sure your name is on every file.
The project should be submitted via the web-based turning program at
http://turnin.cs.wpi.edu:8088/servlets/turnin/turnin.ss
For purposes of turnin, this assignment is project4.