in Programming in C retagged by
1,563 views
7 votes
7 votes

Show the activation records and the display structure just after the procedures called at lines marked $x$ and $y$ have started their execution. Be sure to indicate which of the two procedures named $A$ you are referring to.

Program Test;
    Procedure A;
        Procedure B;
            Procedure A;
            begin
            ……
            end A;
        begin
            y: A;
        end B;
    begin
        B;
    end A;

begin
    x: A;
end Test
in Programming in C retagged by
1.6k views

1 comment

Here is a good explanation.

0
0

1 Answer

1 vote
1 vote

Initially activation stack is empty.

I have used A1, A2, B1, B2 for understanding purpose, which refers to A and B respectively.

Test()
{//Scope of Test begins. In activation record Test is added
    A()
    {
    //Scope of A begins.
    // Activation stack: Test---> A
        B1()
        {
        //Scope of B1 begins.
        // Activation stack: Test---> A--->B1
           A1()
            {
           //Scope of A1 begins
            // Activation stack: Test---> A--->B1--->A1
            }//Scope of A1 ends
            //Activation record before y pt of execution Test---> A--->B1

At y point of execution
            A2()
            {
            //New Activation record of A created
            //Activation stack: Test---> A--->B1--->A2
            }//Scope of A2 ends
        }//End of scope B

//Activation stack: Test---> A
            B2()
            {
            //Activation of B2 added
            //Activation stack: Test---> A--->B2
            }
        }//End of scope A
        //Activation Record before x point of execution: Test

At x point of execution
    A()
    {
    //Activation Record: Test--->A
    }
}//End of scope Test

 

3 Comments

why you named them A1,A2,B1,B2?

aren’t they the same fun.

or if some fun is called in some different scope or within some other fun then renaming is needed?

one minor correction in your answer at Line no. 21 it should be A2 in place of A.

0
0

//New Activation record of A created

It means $A2$ is an activation record of A only 

0
0
edited by

In this answer explanation "At x point of execution" I did not understand how it ends with just one A() fn call. isn't it supposed to call the outermost A() function? so it should also contain activation records of subsequent functions that are contained within outermost A(), right?

0
0

Related questions