retagged by
3,484 views
12 12 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

1 Answer

7 7 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

 

Position:
Show:

Related questions

2 2 votes
1 1 answer
1.9k
1.9k views
Kathleen asked Sep 13, 2014
1,909 views
What type of parameter passing mechanism (call-by-value, call-by-reference, call-by-name, or-by-value result) is the following sequence of actions trying to implement for...
75 75 votes
9 answers 9 answers
40.0k
40.0k views
Kathleen asked Sep 13, 2014
39,969 views
The access times of the main memory and the Cache memory, in a computer system, are $500$ n sec and $50$ nsec, respectively. It is estimated that $80\%$ of the main memor...
54 54 votes
5 answers 5 answers
21.9k
21.9k views
go_editor asked Apr 24, 2016
21,905 views
The following program fragment is written in a programming language that allows global variables and does not allow nested declarations of functions.global int i=100, j=5...
30 30 votes
1 answers 1 answer
11.6k
11.6k views
Ishrat Jahan asked Oct 29, 2014
11,573 views
Consider the program below in a hypothetical language which allows global variable and a choice of call by reference or call by value methods of parameter passing. ...