next up previous
Next: What to turn in Up: Assignment 4: Multi-threaded Programs Previous: Tug of war!

Crash the stacks

1.
Put one of your threads into an infinite loop like this:

int i = 712;
while (i == 712) {
    /* do nothing */
}
printf ("Mo-o-m!  One of my siblings just crashed my stack!!!");

2.
Write a recursive procedure, like factorial, that contains a really big array as a local variable. That way, each activation record is really big, and you can control the depth of the stack by passing different parameters to the procedure.

3.
Using your map of the address space and the size of the local array, figure out how many activation records it will take to crash into the first thread's stack. Run the program and see if you got it right.



Allen Downey
2000-03-06