Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

  1. 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.

  1. 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)?

  2. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

8. Explain the contact hypothesis.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago