13
votes

What is the difference between Compile time, Load time and Execution time?

  • Can someone explain me these three terms in a very simple language?
  • It would be easier to understand if you can provide some examples as well.

Context:

Classically, the binding of instructions and data to memory addresses can be done at any step along the way:

  • Compile time. The compiler translates symbolic addresses to absolute addresses. If you know at compile time where the process will reside in memory, then absolute code can be generated (Static).

  • Load time. The compiler translates symbolic addresses to relative (relocatable) addresses. The loader translates these to absolute addresses. If it is not known at compile time where the process will reside in memory, then the compiler must generate relocatable code (Static).

  • Execution time. If the process can be moved during its execution from one memory segment to another, then binding must be delayed until run time. The absolute addresses are generated by hardware. Most general-purpose OSs use this method (Dynamic).

3
Could you provide a bit more context? Where have you heard of these terms? Without additional context am answer would be a bit vague / general and finding examples would be difficult.Daniel Jour

3 Answers

28
votes

These terms seem self explanatory to me, but here's an attempt at describing them. Links for further reading are included.

Compile time is when your code is being processed by a compiler. In this context, it's talking about a compiler that is transforming your code into an executable binary.

Load time is when the Operating System is reading an executable from long term storage (typically a hard drive) and loading it into short term memory (RAM) from which it can be executed. Generally the hard drive is too slow to feed the CPU, so fast memory is used to store instructions/programs that the CPU is getting ready to execute. This is also when the initial memory allocation is reserved and initialized for use by the program.

Execution time is when a program is executing or running. The instructions are in memory and are being processed by the CPU. Additional memory may be allocated and/or deallocated at this time.

26
votes

Without going too much into how its done, I'll write about what is done. With reference to the "binding" word, here's what I know :

Compile Time Binding : It is the translation of logical addresses to physical addresses at the time of compilation. Now this type of binding is only possible in systems where we know the contents of the main memory in advance and know what address in the main memory we have to start the allocation from. Knowing both of these things is not possible in modern multi-processing systems. So it can be safely said the compile time binding would be possible in systems not having support for multi-processing.

Load Time Binding : It is the translation of the logical addresses to physical addresses at the time of loading. The relocating loader contains the base address in the main memory from where the allocation would begin. So when the time for loading a process into the main memory comes, all logical addresses are added to the base address by the relocating loader to generate the physical addresses.

Run Time Binding : In most modern processors multi-processing is supported. Therefore, there comes the need of shifting the physical addresses from one location to another during run time. This is taken care by the run time binding concept. It is used in Compaction to remove External Fragmentation. It is also used in Virtual Functions.

I hope this solves your doubt!

0
votes

The source code must be compiled into machine code in order to become and executable program. This compilation process is referred to as compile time. A compiled program can be opened and run by a user. When an application is running, it is called runtime.

Binding means association of program instruction data to the physical memory location.

Compile time binding means association of instruction data to physical memory and it is done by compiler.

Similarly load time binding is done by loader and run time binding is done by CPU.