next up previous
Next: Tug of war! Up: Assignment 4: Multi-threaded Programs Previous: Type in the sproc

Find out where the segments are

1.
You can find out where the various segments of memory reside by creating variables in each segment and printing their addresses. To get the address of a variable, use the & operator. For example,
int i;
printf ("0x%x\n", &i);

creates a local variable named i and prints its address in hexadecimal (the 0x prefix is the standard way to indicate that a number is hexadecimal).

2.
Find the location of each of the following: the program text, the static data segment, the heap, the parent's stack and the child thread's stack. Draw a diagram of the address space. How big is the address space?

3.
Do the stacks grow up or down? Does the heap grow up or down? Can you tell how much space the system left for the child thread's stack to grow?

4.
Modify the program so it creates an additional child that also uses the procedure entry as its point of entry. Where in the address space is the second child's stack? See how many children you can create before you run out of space (or maybe run out of something else first--perror will tell you what caused the error).

5.
Repeat this experiment on iris12 and see if the size or layout of the address space is different.


next up previous
Next: Tug of war! Up: Assignment 4: Multi-threaded Programs Previous: Type in the sproc
Allen B. Downey
3/5/1998