0% found this document useful (0 votes)
40 views21 pages

Memory - Management - Exercises and Solution

This document summarizes an exercise on memory management presented by Group 7. It includes 4 exercises involving drawing activation record stacks, display diagrams, and call return trees when calling different procedures. The first exercise involves drawing the stack and display for a calling sequence of procedures P1-P4. The second involves drawing the stack and display for a calling sequence within procedures A and B. The third extends this to procedures A-E. The fourth involves drawing association lists and call return trees for a program with procedures a, b, c, and d.

Uploaded by

kz33252000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views21 pages

Memory - Management - Exercises and Solution

This document summarizes an exercise on memory management presented by Group 7. It includes 4 exercises involving drawing activation record stacks, display diagrams, and call return trees when calling different procedures. The first exercise involves drawing the stack and display for a calling sequence of procedures P1-P4. The second involves drawing the stack and display for a calling sequence within procedures A and B. The third extends this to procedures A-E. The fourth involves drawing association lists and call return trees for a program with procedures a, b, c, and d.

Uploaded by

kz33252000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Memory

Management
Exercises
Presented by Group 7
Group Members

● Khin Oo Thi Han ( UIT - 1226 )

● Khin Zarli ( UIT - 1247 )

● Aw Myat Hay Thi ( UIT - 1240 )

● Ei Ei Thant ( UIT - 1099 )

● Ei Phyu Khaing ( UIT - 1241 )

2
Exercise No (1)

3
1.Consider the following block structure

(a)Draw the activation record stack region that occurs between the static and dynamic chain pointers when
the following sequence of calls,P1,P2,P3,P4,P2 has been made.

P1,P2,P3,P4,P2

Act Rec Pointer

4
Display for calling sequence
(b)Draw a diagram showing the display and
the stack by using calling sequence in no(a).

1 2 3 1 2 3

1 2 3 1 2 3
5
Exercise No ( 2 )

6
(2) Consider the following program fragment:

package K { int h,i;


void main( ) {

void A(inta, intb) { int i, j;


B(h);
}

void B(int w) { int j;


i = 2*w; w
= w+1;
}

int a, b; h= 5; a =3; b=2;


A(a, b);

(a) Draw the activation record stack region that occurs


between the static and dynamic chain pointers during the
B().
7
Display for Calling Sequence

(b) Draw a diagram showing the display and


the stack when execution reaches the B().

8
(c) Draw CRT and hidden stack when execution reaches the B(). CRT with hidden stack

9
Exercise No ( 3 )

10
A, B, C, D, E, B

3) Consider the following block structure (assume


that all variables are int types):

(a) Draw the activation record stack region that


occurs between the static and dynamic chain
pointers when the following sequence of calls A,
B, C, D, E, B has been made.

11
Display for Calling Sequence A,B,C,D,E,B
(b) Draw a diagram showing the display and
the stack by using calling sequence in no (a).

12
(c) Draw CRT without hidden stack after the calling sequence in no (a).

CRT without hidden stack

13
(c) Draw CRT without hidden stack after the calling sequence in no (a).

CRT without hidden stack

14
(d) Draw CRT with hidden stack after the calling sequence in no (a).

CRT with hidden stack

15
(d) Draw CRT with hidden stack after the calling sequence in no (a).

CRT with hidden stack

16
Exercise No ( 4 )

17
Association List
(4) Consider the following program
fragment written in a pseudo-language

program a() {
x: integer; y: integer; x = 1; y = 3;
procedure b() { y: integer; x = 2;
d(); }
procedure c() { x: integer; b(); }
procedure d() { x: integer; z:
integer; x = 4; z = 6; }
c();
}

(a)Draw association list when execution


reaches the d().

18
(b)Draw CRT without hidden stack when execution reaches the d().

CRT without hidden stack

19
(c) Draw CRT with hidden stack when execution reaches the d().

CRT with hidden stack

20
Thank You for Your Attention !

You might also like