18.5k views
5 votes
Show the stack with all activation record instances, including static and dynamic chains, when execution reaches position 1 in the following skeletal program. Assume bigsub is at level 1.

function bigsub() {

function a() {

function b() {

... <----------------------------1

} // end of b

function c() {

...

b();

...

} // end of c

...

c();

} // end of a

...

a();

...

}// end of bigsum

2 Answers

6 votes

Final answer:

The stack with all activation record instances, including static and dynamic chains, when execution reaches position 1 in the given skeletal program.

Step-by-step explanation:

When execution reaches position 1 in the given skeletal program, the stack would consist of the following activation record instances:

  • bigsub() at level 1
  • a() at level 2
  • b() at level 3

The static chain would connect bigsub() to a(), and the dynamic chain would connect a() to b().

Static chains are used to link functions that are in a higher level in the call stack to functions at a lower level. Dynamic chains, on the other hand, connect function calls that are made within the same level of the call stack.

User Peter Ellis
by
6.3k points
6 votes

Answer:

Activation Records

The storage (for formals, local variables, function results etc.) needed for execution of a

subprogram is organized as an activation record.

An Activation Record for “Simple” Subprograms

.

Activation Record for a Language with Stack-Dynamic Local Variables

Dynamic link: points to the top of an activation record of the caller

Step-by-step explanation:

User Dave Dunkin
by
7.0k points