Question
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
-
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 ", &a, &b);
Hypothetical output:
0x7ffd90ed9038, 0x7ffd90ed903c
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.
-
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)?
-
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 ]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started