Open In App

Multistep Processing of a User Program

Improve
Improve
Like Article
Like
Save
Share
Report

Program is a sequence of instructions written by the user that instructs the computer to perform the task of solving some problem. We will now learn more about the various steps a program goes through before it gets executed. The program resides on the disk as a binary executable file. In order to run the program, it must be brought from the disk into the main memory (as the only storage locations which can be directly accessed by the CPU are – Main Memory and Registers – while the register is accessed in one CPU cycle or less, the Main Memory can take many cycles). Now, let us know the detailed steps that the program goes through so that the former task is accomplished. 

As the program to be executed is brought from the disk to the main memory, it is placed within the context of a process, (which is basically a program under execution) where it becomes available for execution on the CPU. During the execution, it accesses data and instructions from the memory and once the execution is completed, the process is terminated and the memory is reclaimed for use by another process. 

The addresses in the source code are generally symbolic (like the variable count). The compiler binds these addresses to relocatable addresses and these are bonded by the linker or loader to the absolute addresses (Binding – mapping from one address space to another). 

The binding of instructions and data to the memory addresses can be done at any of the following steps of program execution: 

 

  1. Compile Time: 
    If we initially know where the process is residing in the memory at the time of compilation, then absolute code can be generated. If the starting location changes, then the code has to be recompiled. 

     

  2. Load Time: 
    If the memory address where the process resides is not known at the compile time, then the compiler must generate relocatable code (does not have a static memory address for running). If the starting address changes, then the program must be reloaded to incorporate this value. 

     

  3. Execution Time: 
    If the process can be moved from one segment to another during its execution time, then binding must be delayed till execution time. Special hardware is required for this type of binding (discussed below). 

     

 

Figure – Multistep Processing of a User Program 

Logical vs Physical Address : 
Logical Address is the address generated by the CPU whereas Physical Address is the one seen by the memory unit (that is the address loaded into memory-address register of the memory). The user program deals with the logical addresses and one never sees the physical addresses. 

Binding addresses at compile time or load time (as discussed above) generate identical logical and physical addresses whereas this is not the case when binding addresses are done at execution time. In the latter case, the physical and logical addresses generated are different. The logical address is referred to as virtual address in this case. At the run time, a hardware device called Memory Management Unit (MMU) does the mapping from virtual address to physical address. 

Dynamic Loading is used for more efficient memory utilization. The advantage of Dynamic Loading is that a particular routine is loaded only when it is required. Dynamically Linked Libraries (DLLs) are the system libraries that are linked to the program when the programs are run. This is the overall brief summary of the multistep processing of a user program, right from the source code stage till the execution. The attached diagram depicts the multistep processing of the program precisely.
 


Last Updated : 07 Feb, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads