The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+18 votes
1.5k views

In the C language

  1. At most one activation record exists between the current activation record and the activation record for the main
  2. The number of activation records between the current activation record and the activation records from the main depends on the actual function calling sequence.
  3. The visibility of global variables depends on the actual function calling sequence
  4. Recursion requires the activation record for the recursive function to be saved in a different stack before the recursive function can be called.
asked in Programming by Veteran (59.4k points)
edited by | 1.5k views

1 Answer

+47 votes
Best answer
  1. Each function call starts a new activation record and since C allows nested function calls more than once activation record can exist between the current activation record and main.
  2. TRUE
  3. Since, C uses static scoping, the actual function calling sequence has no impact on the visibility of global variables. If a variable is not found in the current activation record, it is looked in global address space and this is independent of the calling sequence.
  4. All function calls- whether recursive or not uses the same stack for saving the activation record. There is no need for a different stack as for C compiler a recursive function call and a normal function call make no difference.
answered by Veteran (339k points)
edited by
+1
@arjun sir

thse things are little contradictory explain it more

Each function call starts a new activation record and since C allows nested function calls more than once activation record can exist between the current activation record and main.

 

All function calls- whether recursive or not uses the same stack for saving the activation record. There is no need for a different stack as for C compiler a recursive function call and a normal function call make no difference.
0
Do activation record and stack same?
+3

@srestha

Activation Record

A data structure containing the important state information for a particular instance of a function call (or something that resembles a function call). May exist entirely in memory, or be partially stored in registers. Typically, an ActivationRecord contains the following:

 

  • A pointer to the ActivationRecord of the caller (commonly known as the DynamicChain), though in a language with ContinuationPassingStyle even this isn't necessary (when the function returns, it does so via the supplied continuation; rather than the DynamicChain).
  • In languages which allow nested LexicalScoping, a pointer to the ActivationRecord of the enclosing scope (aka the ReferencingEnvironment) - this pointer is called the StaticChain. In most such languages, it is generally a requirement that somewhere up the call chain, the enclosing function have been called (but in concurrent languages it may have been called in a different thread). In languages like C/C++ where nested LexicalScopes are disallowed (or restricted), a StaticChain is unnecessary. Java InnerClasses also seem to be designed in order to avoid aStaticChain.
  • Local variables (frequently cached in registers)
  • Actual parameters to the function (also frequently cached in registers)
  • Space for the (eventual) return value of the function.


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

34,770 questions
41,731 answers
118,876 comments
41,381 users