top of page

Introduction to Program Execution Cycle

Updated: Sep 27, 2023

Program Execution Cycle

In computers, to execute a program is to run the program in the computer, and, by implication, to start it to run. In usage, people run programs and systems execute them. That is, a system user asks the system to run the program (or sets it up so that this happens automatically at a certain time) and, as a result, the system executes the program. Typically, we don't say that a program is executing; we say that it is running.

A computer processor executes an instruction, meaning that it performs the operations called for by that instruction.

Before the program is executed, the program should be converted from high-level program code to low-level program code into machine code which the computer can execute; called translator.

Program Execution Cycle 1

What is Translator?

The translation process converts code written by a programmer into machine code that a computer can execute. Machine code is a type of low-level language, which has ones and zeros. So, what the translator does is converts the high-level code you create in a programming language to machine code.

Without translators, you would have to code in machine language. Each high-level programming language that you know uses one of three translation methods:

  1. Compiler

  2. Interpreter

  3. Hybrid (Compiler + Interpreter)

1. Compiler

A compiler is software that converts source code written in a high-level language into low-level code for execution.

Some popular compiled programming languages include:

  • C

  • C++

  • Go

  • Ada

  • Fortran


  • Lisp

  • Objective-C

  • Swift

Program Execution Cycle 2

The compiler has several phases. Each phase transforms the code from one state to another. The goal of each compiler phase is to create an output that is easier for the succeeding phase to manipulate. The general structure of a compiler is as follows:

Program Execution Cycle 3

  • Scanner: this phase takes a stream of characters and groups them into tokens that represent identifiers, string literals, and so on.

  • Parser: this phase groups the tokens based on the grammar of the source programming language. It creates an abstract syntax tree which is a collection of expressions that make up the program.

  • Semantics: this phase conducts a semantic analysis on the abstract syntax tree (AST). It uses the rules of the source language to add meaning by assigning types to the AST expressions and checking their validity. The AST then becomes an intermediate representation.

  • Intermediate Representation (IR): this phase converts the original program’s source code to machine code. It produces a simplified version of assembly code. The IR uses one or more optimizers to improve the IR code and to collect information for the machine it is running on. An optimizer can make a program more efficient, faster, or even smaller.

  • Code Generator: this phase consumes the optimized IR code and converts it into machine code.


An interpreter is a program that translates and executes a single line of code at a time. This process repeats until the interpreter arrives at the final line of code in the given program or script.

Some popular interpreted programming languages include:

  • Python

  • JavaScript

  • Perl



Program Execution Cycle 5

The Interpreter takes two inputs. First, it takes the entire source code (program). It then reads the first line of the program (as an input), translates, and executes it. If that line executes correctly, it moves on to the next line in the program or script.


Hybrid translation employs a compiler and an interpreter. Hybrid translation compiles high-level source code to a lower-level form, such as bytecode. It then uses an interpreter to run that bytecode.

Some popular hybrid programming languages include:

  • Java

  • C#

  • Visual Basic

  • Erlang

  • F#

Program Execution Cycle 6

Hybrid translation may differ from one programming language to another but will use this general structure. One of the more popular programming languages that use hybrid translation is Java. The Java compiler translates its source code into Java Virtual Machine (JVM) bytecode. The interpreter then translates the JVM bytecode to machine code.


A linker is a program in a system, also known as a link editor and binder, which combines object modules into a single object file. Generally, it is a program that performs the process of linking; it takes one or multiple object files, which are generated by compiler. And, then combines these files into an executable files. Modules are called for the different pieces of code, which are written in programming languages. Linking is a process that helps to gather and maintain a different piece of code into an executable file or single file. With the help of a linker, a specific module is also linked into the system library.

Program Execution Cycle 8

Types of Linking:

There are two types of linking, which are as follows:

1. Static Linking

Static linking is a kind of linking that is performed during the compilation of a source program in which linking is performed before the execution of the file or object. On the other hand, the linker produces a result at the time of copying all library routines into the executable image, which is known as static linking. As compared to dynamic linking, it may need more memory storage and disk space.

However, when it runs on the system, it does not need the presence of the library that makes it more portable. It generates a fully linked object file that would be able to load and run and takes a collection of the relocatable object file and command-line argument. Two major tasks are performed by the static linker, which is discussed below:

  • Symbol resolution: In this, each symbol has a predefined task, and it associates each symbol exactly with one symbol definition from which they belong to.

  • Relocation: Its function is to modify symbol references to the relocated memory location and relocate the code and data section.

2. Dynamic linking

Another type of linking is dynamic linking, which is performed at the run time, in which multiple programs can share a single copy of the library. It means, each module having the same object can share information of an object with other modules rather than linking the same object repeatedly into the library.


A loader is a component that locates a given program (which can be an application or, in some cases, part of the operating system itself) in offline storage (such as a hard disk ), loads it into main storage (in a personal computer, it's called random access memory ), and gives that program control of the computer (allows it to execute its instruction s).

A program that is loaded may itself contain components that are not initially loaded into main storage, but can be loaded if and when their logic is needed. In a multitasking operating system, a program that is sometimes called a dispatcher juggles the computer processor's time among different tasks and calls the loader when a program associated with a task is not already in main storage.

Program Execution Cycle 9

Loader Function: The loader performs the following functions:

  1. Allocation

  2. Linking

  3. Relocation

  4. Loading


  • Allocates the space in the memory where the object program would be loaded for Execution.

  • It allocates the space for program in the memory, by calculating the size of the program. This activity is called allocation.

  • In absolute loader allocation is done by the programmer and hence it is the duty of the programmer to ensure that the programs do not get overlap.

  • In reloadable loader allocation is done by the loader hence the assembler must supply the loader the size of the program.


  • It links two or more object codes and provides the information needed to allow references between them.

  • It resolves the symbolic references (code/data) between the object modules by assigning all the user subroutine and library subroutine addresses. This activity is called linking.

  • In absolute loader linking is done by the programmer as the programmer is aware about the runtime address of the symbols.

  • In relocatable loader, linking is done by the loader and hence the assembler must supply to the loader, the locations at which the loading is to be done.


  • It modifies the object program by changing the certain instructions so that it can be loaded at different address from location originally specified.

  • There are some address dependent locations in the program, such address constants must be adjusted according to allocated space, such activity done by loader is called relocation.

  • In absolute Loader relocation is done by the assembler as the assembler is aware of the starting address of the program.

  • In relocatable loader, relocation is done by the loader and hence assembler must supply to the loader the location at which relocation is to be done.


  • It brings the object program into the memory for execution.

  • Finally it places all the machine instructions and data of corresponding programs and subroutines into the memory. Thus program now becomes ready for execution, this activity is called loading.

  • In both the loaders (absolute, relocatable) Loading is done by the loader and hence the assembler must supply to the loader the object program.

Difference between Linker and Loader



A linker is an important utility program that takes the object files, produced by the assembler and compiler, and other code to join them into a single executable file.

A loader is a vital component of an operating system that is accountable for loading programs and libraries.

It uses an input of object code produced by the assembler and compiler.

It uses an input of executable files produced by the linker.

The foremost purpose of a linker is to produce executable files.

The foremost purpose of a loader is to load executable files to memory.

Linker is used to join all the modules.

Loader is used to allocate the address to executable files.

It is accountable for managing objects in the program’s space.

It is accountable for setting up references that are utilized in the program.

The Tech Platform



bottom of page