Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Do I have enough information to do this problem and What exactly are the static and dynamic Chains? I am not a programmer and I am trying to get this right

Do I have enough information to do this problem and What exactly are the static and dynamic Chains? I am not a programmer and I am trying to get this right

Computer Science

Do I have enough information to do this problem and What exactly are the static and dynamic Chains? I am not a programmer and I am trying to get this right.

Show the stack with all activation record instances, including static and dynamic chains, when executions reaches position 1 in the following skeletal program. Assume Bigsub is at level 1.

procedure Bigsub is
procedure A
procedure B is
begin -- of B
... <-- 1
end; -- of B
procedure C is
begin - of C
...
B;
...
end; -- of C
begin - of A
...
C;
...
end; -- of A
begin -- of Bigsum
...
A;
...
End; -- of Bigsum

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

 

1. Static chain is a chain of static links that connects its activation record instance (ARI)to all of its static ancestors ARIs. Static chains connect the set of stack frames in each dynamic environment as a tree.

2. Dynamic chains is the collection of dynamic links in the stack at a given time.

In Procedure Bigsub, the dynamic chains just link each frame together in stack order.
The first frame on the stack (the top) points to the second frame, which points to
the third frame and so forth. Here is the call sequence produced by the above code:

BIGSUB -> A -> C -> B

This is just the stack, bottom to top (assume the stack grows "up").

B
C
A
BIGSUB

The dynamic chain is just the opposite:

B -> C -> A -> BIGSUB
(Think of the dynamic chain as encoding the "was called by" relation.)

To find static chains, go through the call chain and then, for each
frame, determine its static ancestors by inspecting the code (declaration nesting).

B -> A -> BIGSUB
C -> A -> BIGSUB
A -> BIGSUB

These links are all threaded together in the runtime stack. (Think of the static
chain as encoding the "child of" relation.) This can get a bit more confusing when
we have recursive activations on the stack. Then we need to distinguish each
activation but that's not the case in this example.