Run-time Storage Organization
The run-time environment is the structure of the target computers registers and memory that serves to manage memory and maintain information needed to guide a programs execution process.
Types of Runtime Environments –
- Fully Static :
Fully static runtime environment may be useful for the languages in which pointers or dynamic allocation is not possible in addition to no support for recursive function calls.
- Every procedure will have only one activation record which is allocated before execution.
- Variables are accessed directly via fixed address.
- Little bookkeeping overhead; i.e., at most return address may have to be stored in activation record.
- The calling sequence involves the calculation of each argument address and storing into its appropriate parameter location and saving the return address and then a jump is made.
- Stack Based :
In this, activation records are allocated (push of the activation record) whenever a function call is made. The necessary memory is taken from the stack portion of the program. When program execution return from the function the memory used by the activation record is deallocated (pop of the activation record). Thus, the stack grows and shrinks with the chain of function calls.
- Fully Dynamic :
Functional language such as Lisp, ML, etc. use this style of call stack management. Silently, here activation record is deallocated only when all references to them have disappeared, and this requires the activation records to dynamically freed at arbitrary times during execution. Memory manager (garbage collector) is needed.
The data structure that handles such management is heap an this is also called as Heap Management.
Activation Record –
Information needed by a single execution of a procedure is managed using a contiguous block of storage called “activation record”.
An activation record is allocated when a procedure is entered and it is deallocated when that procedure is exited. It contain temporary data, local data, machine status, optional access link, optional control link, actual parameters and returned values.
- Program Counter (PC) – whose value is the address of the next instruction to be executed.
- Stack Pointer (SP) – whose value is the top of the (top of the stack, ToS).
- Frame pointer (FP) – which points to the current activation.
Activation records are allocated from one of static area (like Fortran 77), stack area (like C or Pascal) and heap area (like lisp).
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.