A Vision to Run time Environments

Run time environments means how a program should be loaded in the operating system and what is the support that your program needs.

                  By runtime, we mean a program in execution. Runtime environment is a state of the target machine, which may include software libraries, environment variables, etc., to provide services to the processes running in the system.

               Runtime support system is a package, mostly generated with the executable program itself and facilitates the process communication between the process and the runtime environment. It takes care of memory allocation and de-allocation while the program is being executed.

 

Activation Trees

A program is a sequence of instructions combined into a number of procedures. Instructions in a procedure are executed sequentially. A procedure has a start and an end delimiter and everything inside it is called the body of the procedure. The procedure identifier and the sequence of finite instructions inside it make up the body of the procedure. The execution of a procedure is called its activation.

                  We assume that the program control flows in a sequential manner and when a procedure is called, its control is transferred to the called procedure. When a called procedure is executed, it returns the control back to the caller. This type of control flow makes it easier to represent a series of activations in the form of a tree, known as the activation tree.

 

Storage Allocation

Runtime environment manages runtime memory requirements for the following entities:

 

Code : It is known as the text part of a program that does not change at runtime. Its memory requirements are known at the compile time.

Procedures : Their text part is static but they are called in a random manner. That is why, stack storage is used to manage procedure calls and activations.

Variables : Variables are known at the runtime only, unless they are global or constant. Heap memory allocation scheme is used for managing allocation and de-allocation of memory for variables in runtime

 

1) Static:

  • Allocation is done at compile time.
  • Bindings do not change.
  • one activation record per procedure.
  • array by default is static.
  • Activations (function call) can have permanent lifetime in case of static allocation.

Disadvantages:

  • Recursion is not supported.
  • sizeof data object must be be known at compile time.
  • data structure can't be created dynamically.

 

2) Stack

  • whenever a new activation begins activation record is pushed on to the stack and whenever activation ends ,activation record is popped off.
  • local variable are bound to fresh storage.
  • Activations  can have nested lifetime in case of stack allocation.

 

Disadvantages:

  • local variable can't be retained once activation end.

i.e f()

         { int count=0;

          count++;

 

          }

 

3) Heap:

  • Allocation and deallocation canbe in any order.
  • In c programming language to management the hole or free space in heap we are using First fit.
  • Activations can have Arbitrary  lifetime in case of heap allocation.

Disadvantage:

Heap management is overhead.

 

Contributor's Info

Created:
0Comment