Project3 - Memory - CS180 Synopsis Project 3 Due: Nov 10...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS180 Project 3 Due: Nov 10 Synopsis Write some small C/C++ programs to discover how the OS (of your choice) lays out the memory for user programs. Use your data to answer some specific questions. Motivation A well written program will not depend on the layout of memory sections chosen by the OS. However the layout is a matter of curiosity. When you run a program, you can discover where things are laid out in memory by printing their address. C/C++ makes this easy because you can get the addresses of variables and procedures. For instance, consider the four values output by this code: int GlobalVar; main(. ..) { int LocalVar; printf("Globals: 0X%8x\n", &GlobalVar); // Address of a global printf("Code: 0X%8x\n", &main); // Address of some code printf("Stack: 0X%8x\n", &LocalVar); // Address of var on stack printf("Libraries: 0X%8x\n", &printf); // Address of library code } As another example, you can discover in which direction the stack grows, and by how much it grows, by examining the address of a local
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Project3 - Memory - CS180 Synopsis Project 3 Due: Nov 10...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online