新手请高手帮忙回答一下问题,谢谢!!!!!
发表于 : 2010-08-19 17:06
Part A
Method
Use the pseudofiles in the /proc directory to answer the questions in Part A. The answer to many of the questions
will vary based on system state at the time (eg uptime, memory usage, etc.); just report the answers you get from
/proc.
(Hint: you may want to Google linux man proc to find out more about the information available in different proc
files.)
Questions for Part A
1.What is the CPU vendor ID and model name?
2.Which version of the kernel is installed?
3.Which version of the GNU compiler collection (gcc) is running?
4.How long in days, hours, and minutes has it been since the system was last booted? (Hint: you'll have to do some arithmetic.)
5.How much RAM does the computer have (in megabytes)?
6.How much memory (in megabytes) is currently free?
7.How much time have each of the processors been spent executing in user mode? System mode? Idle?
8.How many interrupts have occurred?
9.How many processes have been created since the system was booted?
10.How many read and write operations have been performed on each disk device?
Part B
In Part B, you will be writing a program to answer some of the questions in Part A. Specifically, have your program report the following:
1.CPU vendor ID and model
2. Which version of the kernel is running.
3. Which version of gcc is installed.
4.Amount of time since the system was last booted, in the form dd days, hh hours, mm minutes, and
ss seconds. The twist: if the system has been up for less than 1 day, don't print the days. Likewise for
hours and minutes (though you'd be hard-pressed to run the program less than one minute after starting the system!).
NOTE: here's where we separate the men from the boys! Extra credit will be given if you are able to express the time grammatically.
For example:
3 days, 4 hours, 37 minutes, and 10 seconds.
2 hours, and 10 minutes.
1 day, 59 minutes, and 1 second.
To test this, you'll need to set the days, hours, minutes, and seconds by hand instead of calculating from
uptime.
5. The amount of memory configured into this computer in gigabytes.
6. The amount of memory currently available.
Part C
In part C, you will be modifying your program so it looks up and reports information from the /proc/stat and
/proc/diskstats files, specifically:
1. The amount of time that each CPU has spent in user mode, system mode, and idle.
2. The number of interrupts that have occurred since the system was booted.
3. The number of context switches that the kernel has performed.
4. The number of processes that have been created since the system was booted.
5. The number of disk operations (read and write) that have been performed on each disk device.
Design your program so that it accepts a switch from the command line, eg.
-b runs part B.
-c runs part C.
No arguments runs both parts B and C.
--help will print instructions as specified above.
Remember to check for invalid arguments!
For this you will need to reference the bash command line variables $1, $2, etc.
Hint: $# tells you how many arguments are on the command line.
Method
Use the pseudofiles in the /proc directory to answer the questions in Part A. The answer to many of the questions
will vary based on system state at the time (eg uptime, memory usage, etc.); just report the answers you get from
/proc.
(Hint: you may want to Google linux man proc to find out more about the information available in different proc
files.)
Questions for Part A
1.What is the CPU vendor ID and model name?
2.Which version of the kernel is installed?
3.Which version of the GNU compiler collection (gcc) is running?
4.How long in days, hours, and minutes has it been since the system was last booted? (Hint: you'll have to do some arithmetic.)
5.How much RAM does the computer have (in megabytes)?
6.How much memory (in megabytes) is currently free?
7.How much time have each of the processors been spent executing in user mode? System mode? Idle?
8.How many interrupts have occurred?
9.How many processes have been created since the system was booted?
10.How many read and write operations have been performed on each disk device?
Part B
In Part B, you will be writing a program to answer some of the questions in Part A. Specifically, have your program report the following:
1.CPU vendor ID and model
2. Which version of the kernel is running.
3. Which version of gcc is installed.
4.Amount of time since the system was last booted, in the form dd days, hh hours, mm minutes, and
ss seconds. The twist: if the system has been up for less than 1 day, don't print the days. Likewise for
hours and minutes (though you'd be hard-pressed to run the program less than one minute after starting the system!).
NOTE: here's where we separate the men from the boys! Extra credit will be given if you are able to express the time grammatically.
For example:
3 days, 4 hours, 37 minutes, and 10 seconds.
2 hours, and 10 minutes.
1 day, 59 minutes, and 1 second.
To test this, you'll need to set the days, hours, minutes, and seconds by hand instead of calculating from
uptime.
5. The amount of memory configured into this computer in gigabytes.
6. The amount of memory currently available.
Part C
In part C, you will be modifying your program so it looks up and reports information from the /proc/stat and
/proc/diskstats files, specifically:
1. The amount of time that each CPU has spent in user mode, system mode, and idle.
2. The number of interrupts that have occurred since the system was booted.
3. The number of context switches that the kernel has performed.
4. The number of processes that have been created since the system was booted.
5. The number of disk operations (read and write) that have been performed on each disk device.
Design your program so that it accepts a switch from the command line, eg.
-b runs part B.
-c runs part C.
No arguments runs both parts B and C.
--help will print instructions as specified above.
Remember to check for invalid arguments!
For this you will need to reference the bash command line variables $1, $2, etc.
Hint: $# tells you how many arguments are on the command line.