Similar questions 2 more →
Runtime Environments & Parameter Passing


Answer & solution
Answer: Bottom to top: Main, A1, B1, A2, B2. Dynamic links follow the call chain; static links B2→A2, A2→Main, B1→A1, A1→Main. (no official key was published)
Distinguish a procedure's lexical parent from the activation that calls it. The dynamic link records the caller; the static link records the active instance of the enclosing lexical scope. Calls to A from inside B are recursive calls to a procedure declared directly inside Main, not declarations of a new A inside B.
Trace the shown calls. Main calls A1, which calls B1. B1's call to C1 creates only the fourth record, and C1 makes no further calls. C1 returns before the following call to A2, so its record has been removed. A2 is then the fourth record, and its call to B2 creates the fifth. At any matching five-record stage of this call pattern, the active chain is therefore:
Stack position Activation Local slot Dynamic link Static link
TOP B2 B2.Z A2 A2
A2 A2.Y B1 Main
B1 B1.Z A1 A1
A1 A1.Y Main Main
BOTTOM Main Main.X null nullOther ordinary record fields, such as a return address and saved registers, may exist but are not assigned values by the problem. A1.Y and A2.Y are distinct storage cells, as are B1.Z and B2.Z. No numeric values for X,Y,Z can be recovered from the ellipses. The completed C1 record, including its separate C1.Z slot, is absent.
The dynamic chain is B2→A2→B1→A1→Main. The different static chain from B2 is B2→A2→Main. In particular, A2's static link must not point to B1 merely because B1 called it. To create A2, B1 can follow its own static chain B1→A1→Main to find A's lexical parent. This is the central distinction the example tests.