GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
148 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 (36.3k points)   | 148 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.5k 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 (7.2k 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 (52.4k 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 (685 points)  


Top Users Mar 2017
  1. rude

    4018 Points

  2. sh!va

    2994 Points

  3. Rahul Jain25

    2804 Points

  4. Kapil

    2608 Points

  5. Debashish Deka

    2104 Points

  6. 2018

    1414 Points

  7. Vignesh Sekar

    1336 Points

  8. Bikram

    1218 Points

  9. Akriti sood

    1186 Points

  10. Sanjay Sharma

    1016 Points

Monthly Topper: Rs. 500 gift card

21,446 questions
26,757 answers
60,936 comments
22,954 users