|
For a program to run within the common language runtime and benefit from the managed execution environment, you need to write the source code of the program in a CLS-compliant language.
Step-1
The compilers of CLS-compliant languages compile the source code and generate an intermediate code, called MSIL code, and metadata. MSIL Code contains a CPU independent set of instructions, which describes how to load, store, initialize, and call. They also contains instructions to perform arithmetic and logical operations, access memory directly, control the flow of execution, handle exceptions and perform other operations. methods on objects
Step-2
Before you execute the MSIL code, you need to compile it into CPU-specific instructions. To execute the code, the runtime requires information about the code that is in the metadata. The metadata describes the code and defines the types that the code contains as well as references to other types that the code uses at run time. MSIL Code and metadata both located in the .PE (portable executable) file.
Step-3
When we execute .PE file, the class loader loads the MSIL code and metadata from the portable executable file into the run-time memory.
Step-4
After the MSIL code and metadata are loaded into the memory, the code manager calls the entry point method, which is Main, Win Main or DllMain method. An entry-point method is the first method to be executed when you run your application.
Step-5
The garbage collector performs periodic checks on the managed heap to identify the objects that are no longer required by the program and removes them from memory.
Step-6
The applications running within the common language runtime can utilize the managed multithreading support. The .NET Framework allows a single process to be divided into one or more sub processes called application domains. Each application domain can contain one or more threads. The runtime monitors all the threads that have executed code within its process .
Step-7
The common language runtime also allows managed code to interoperate with unmanaged code. One of the components of the common language runtime is the COM marshaler, which performs marshaling of data when data passes between managed and unmanaged execution environments.
Step-8
Then with the help of JIT the IL code is converted into Native code or we can say Intermediate set of instructions are converted into CPU set of instruction.
Note:- The above steps are known as called managed execution process.
|