1. The ultimate aim of this question is to find out how your Unix system layouts different parts of your process in the virtual memory. The question consists of three parts. The first part is to complete a program that prints out the memory addresses of various components of the process (eg, global variables, local variables, dynamically allocated variables, functions, command line arguments, and environment variables). This program is then used in the second part to recreate a snapshot of the memory layout of the process. Finally in the third, you will answer a number of questions related to the memory management based on your observation and analysis.
Complete the following C program, memory.c, so that it displays the addresses of
functions f1, f2, and main;
all string literals such as "Hello, world!";
all initialized global variables;
all un-initialized global variables;
all dynamically allocated memories;
all formal parameters in functions;
all local variables;
start and end of its command line arguments;
start and end of its environment (variables and values)
2. Based on the information generated from the above program, produce a memory map table showing the layout of literals, initialised global variables, uninitialised global variables, formal parameters of each function, local variables, dynamically allocated variables, functions, environment and command line arguments in the memory when the program runs at label L in function f2.
The memory map table must show the addresses of each variable, literal, and function and their sizes. It should also show the start and end addresses of the environment and the command line arguments and their sizes.
The memory map table must contain at least the following columns:
The start address of an entity such as a variable or a function
The length of the storage space of the entity in bytes
The name of the entity, such as global_pointer1 or Hello, world!
The nature of the entity, such as function, or uninitialsed global variable
The memory section, eg, environment, command line arguments, code (or text), global initialised data, global uninitialed data, stack, heap etc.
In addition, you must use seven different background colours to highlight the following seven memory sections as indicated below::
[Green] initialised global variables (including constants and literals)
[Red] uninitialised global variables
[Blue] stack (containing the local variables and returning addresses of function calls)
[Magenta] heap (containing the dynamically allocated memories)
[Yellow] code (functions)
[Cyan] process environment
[White] command line arguments
Please also note that in your memory table, the memory addresses must be strictly sequential, from the lowest address to the highest address to reflect how different components of a running program are layout in the virtual memory. Your memory table will not be accepted if the addresses are not lined up sequentially in the table. If you find that components from one section are split in more than one continuous area of memory, it is a sure indication that there is something wrong with your memory map and you should find out what went wrong and fix it.
3. Based on the experiment and analysis you have carried out in 1 and 2 above, answer the following questions:
What is the size of the virtual address space of that process?
How does the operating system on your machine layouts the following process components in the virtual address space: command line arguments, environment, literals, initialised global variables, uninitialised global variables, functions, formal parameters and local variables of a function, and dynamically allocated variables (or memories)?
Bu iş için 6 freelancer ortalamada $75 teklif veriyor
I am very proficient in c and c++. I have 16 years c++ developing experience now, and have worked for more than 7 years. My work is online game developing, and mainly focus on server side, using c++ under Linux environ Daha Fazla
Hello dear Hiring manager I have read your job post & being an expert Web developer, I offer myself for the job. I am having extensive knowledge and 5+ years of experience in PHP & WordPress website development u Daha Fazla
Over 8 years of software development experience across various domains. Primary skills include C/C++ on Windows as well as Linux platform. Good at shell scripting. Expert in debugging.
I have worked in research organisations and feeling extremely comfortable in the C programming, Data Structures and Operating System concepts. I have worked in this area for last 3 -4 years. You can trust on me as its Daha Fazla