GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
139 views
Consider the following two statements:
 S1: Activation records can have permanent lifetime in case of static allocation.
S2: Activation records can have nested lifetime in case of stack allocation.
Which of the option is correct regarding S1 and S2 respectively
(A) True. True
(B) True. False
(C) False. True
 (D) False. False
asked in Compiler Design by Veteran (35.9k points)   | 139 views
option c ?
Its A.

4 Answers

+2 votes

Activation records have Permanent Lifetime in case of Static Allocation, 
bcoz in case of Static Allocation, Activation records r fixed in static memory area so why it supports function calling but not recursion
Nested Lifetime in case of Stack Allocation
bcoz in case of Stack Allocation, Activation record are pushed into stack area during function call or recursion nd popped out on function return. so why these r nt permanent
Hence ans is A

answered by Veteran (10.3k points)  
But why is it permanent ? It will also get destroyed after main is finished ? I just have doubt with the word "PERMANENT" ?
Permanent is used in the sense that a variable is bound to a fixed location in static allocation.

Yes ultimately everything gets destroyed after program termination!! :p
^ u r correct
+1 vote

Activation records have Permanent Lifetime in case of Static Allocation, Nested Lifetime in case of Stack Allocation and Arbitrary Lifetime in case of Heap Allocation.

So, option A.

answered by Boss (6.8k points)  
How is it permanent in static, won't it be destroyed after main returns or finishes ?
Provide explaination if possible ?
+1 vote

Activation Record has 3 kind of allocation

1)Static allocation

2)Stack Allocation

3) Heap Allocation

Static Allocation means it is in a fixed location of memory. Doesnot change when program executes.No change required at runtime.

Stack Allocation means it works like LIFO. So, requires recursive function calls

Link

answered by Veteran (51.6k points)  
0 votes
b)Stack/Heap allocation is used in dynamic storage allocation , also recursion is supported here which means there will each activation record for each procedure call i.e. nested ARs so as each procedure completes its work its AR  gets deleted.

Moreover there is dynamic chain which provides stack nature of Activation Record

a) Activation Records are created at compile time and in static allocation method and are removed when programme is over(or after running garbage collector) So we can say that ARs have permanent lifetime.

here permanent means during all course of programme running.
answered by Junior (539 points)  

Related questions

0 votes
2 answers
1
asked in Compiler Design by ManojK Veteran (35.9k points)   | 133 views
0 votes
1 answer
2
asked in Digital Logic by Samujjal Das Boss (6.8k points)   | 264 views
0 votes
1 answer
3
asked in Algorithms by pps121 Active (1.1k points)   | 34 views
Members at the site
Top Users Feb 2017
  1. Arjun

    4676 Points

  2. Bikram

    4004 Points

  3. Habibkhan

    3738 Points

  4. Aboveallplayer

    2966 Points

  5. sriv_shubham

    2278 Points

  6. Smriti012

    2212 Points

  7. Arnabi

    1814 Points

  8. Debashish Deka

    1788 Points

  9. sh!va

    1444 Points

  10. mcjoshi

    1444 Points

Monthly Topper: Rs. 500 gift card

20,788 questions
25,938 answers
59,532 comments
21,923 users