GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
119 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.4k points)   | 119 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 Boss (9.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 (5.5k 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 (49.7k 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 (499 points)  
Top Users Jan 2017
  1. Debashish Deka

    8126 Points

  2. sudsho

    5042 Points

  3. Habibkhan

    4706 Points

  4. Vijay Thakur

    4458 Points

  5. Bikram

    4348 Points

  6. saurabh rai

    4212 Points

  7. Arjun

    4010 Points

  8. santhoshdevulapally

    3722 Points

  9. GateSet

    3292 Points

  10. Sushant Gokhale

    3286 Points

Monthly Topper: Rs. 500 gift card

19,122 questions
24,033 answers
52,725 comments
20,276 users