Reputation: 1243
Show the stack with all activation record instances, including static and dynamic chains, when execution reaches the indicated position in the skeleton program below. Assume Bigsub is a level 1 and the order of subprogram invocation is Bigsub calls A, A calls B, B calls A, A calls C, C calls D.
procedure Bigsub;
procedure C; forward;
procedure A;
procedure B;
end; {B}
end; {A}
procedure C;
procedure D;
*** Here is the point ***
end; {D}
end; {C}
end; {Bigsub}
I have some questions similar to this one. I don't understand what exactly is asked, what are dynamic and static chains. I have this image below which shows the stack and that's what I understand, but I don't what those arrows represent. Also, does the image lack activation record instaces or is it good as a solution?
Upvotes: 0
Views: 5499
Reputation: 329
A static chain is a chain of static links that connect certain activation record instances in the stack. dynamic chains is a collection of dynamic links in the stack at a given time. In your case whenever you say this "calls" that then add a dynamic chain there.As for static chain, you just have to see which function is static to which one.one. Ok for example C is nesting D so C and D has static chain as so forth.
Upvotes: 2