Question: create any c program you wish that prints the addresses...
Create any C program you wish that prints the addresses of two
variables: an integer and a constant integer. Then run “pmap” to
visualize the memory usage, and answer the questions that follow.
Include program output in your report. The following example uses
the %p format specifier to print a pointer value (address) and the
“address of” operator (&) to obtain the pointer:
int a = 0; // Regular integer
const int b = 0; // Constant integer
// Print the pointer values (addresses) in hexadecimal printf("%p, %p\n", &a, &b);
a. Run “top” and find your process in the list. How well does the total virtual memory (VIRT) reported by
“top” compare to the amount displayed by “pmap”? Are they the same or different? In your report, include the relevant output from “pmap” and “top”, and describe the similarity or difference. Note: some Linux computers may show the same values, and some may show different values. You are not required to explain any differences.
b. In your report, include the output that shows the addresses of two variables. What is the name of the memory segment(s) (far right column) in which those variables are located? What are the permissions for that segment? Do the permissions agree with the concept of a “constant” (read-only)?
c. Suppose “pmap” produced the output line shown below for a memory segment. What is the maximum hexadecimal address for that memory segment? What is the maximum possible hexadecimal starting address for a 4-byte integer in that memory segment?
00007f7c01248000 8K rw--- [ anon ]