The Linux /proc file system is a pseudo file system that exists only in kernel memory and
Question:
The Linux /proc file system is a "pseudo" file system that exists only in kernel memory and is
used primarily for querying various kernel and per-process statistics. Although the /proc file
system is virtual, you can open and read the files the same way as any other file. You can
therefore start this assignment without the class discussing the /proc file system in class (which
will be brief).
You will answer questions about turing by writing a program that reads some virtual files in the
/proc/sys/kernel/ directory, and the four virtual files: /proc/cpuinfo, /proc/uptime,
/proc/stat, and /proc/swaps.
a) Review the C++ string class and use it in this program. Use member functions of the string
class to process strings, e.g. to search for a substring (instead of using loops).
b) In /proc/cpuinfo, the majority of the input fields repeat for each processor. Processor
numbers need not be contiguous, so you need to count the number of processors. Each processor
block in the /proc/cpuinfo corresponds to a CPU core, and a physical chip can have multiple
cores.
c) To get the number of physical multi-core chips, you must keep track of the number of physical
ids.
d) Look at the "cpu cores" field to get the number of cores for each physical multi-core chip.
e) You may only read each file once and you do not know which order the keywords will come
in, so you need to read the file, save the fields you need, and then format your output.
f) The file /proc/stat records information about the system since it was started, including:
cpu
Total CPU time (unit is architecture dependent. 1/100ths of a second for this
assignment) spent in user mode, low-priority user mode (nice mode), system
mode, idle, and others.
cpuN
Times for CPU N.
g) /proc/uptime provides two numbers. Use the manual page to find out what they are.
h) The file /proc/swaps provides information on swap devices. The units of size and usage are
kilobytes.
i) Express each output in a numbered complete sentence, e.g.:
A: Questions about turing:
1. Turing has __ processors.
2. Turing has __ physical multi-core chip. (if there is only one: 1 physical
2
multi-core chip.)
...
j) Command "man proc" is the manual page and can give you more details of the /proc file
system.
Expected output:
A. Questions about turing's OS. Read the following files under the directory /proc/sys/kernel/
(Make the output human readable):
1. ostype
2. hostname
3. osrelease
4. version
B: Questions about turing's processor:
1. How many processors (CPU cores) does turing have?
2. How many physical multi-core chips?
3. How long has it been up in seconds?
4. Express that time in days, hours, minutes and seconds
(e.g., 7 days, 1 hour, 2 minutes, and 4.3 seconds)
C. For processor 0, answer these questions:
1. Who is the vendor?
2. What is the model name?
3. What is its physical address size?
4. What is its virtual address size?
D. For processor 0, answer these questions:
1. How long has it spent time in user mode in seconds (including low-priority user mode)?
2. How long has it spent time in system mode in seconds?
3. How long has it been idle in seconds?
4. How long has it been idle in days, hours, minutes and seconds?
E. What is the size of turing's swap device in MB?
Auditing and Assurance services an integrated approach
ISBN: 978-0132575959
14th Edition
Authors: Alvin a. arens, Randal j. elder, Mark s. Beasley