retagged by
1,546 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
retagged by

1 Answer

1 votes
1 votes

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

 

Related questions

22 votes
22 votes
3 answers
4