Archive

Author Archive

Understanding CLR components

April 7, 2009 Leave a comment

CLR consists of various components that provide the run-time environment and run-time services. These components include– Class Loader,MSIL to native code compiler,Code manager,Garbage Collector,Security Engine,Type Checker,Thread Support,Exception Manager,Debug Engine,COM Marshaler,Base Class Library Support.

For a program to run within the CLR and benefit from the managed execution environment,you need to write the source code of the program in a CLS-compliant language.The compilers of CLS-compliant languages compile the source code and generate an intermediate code,called MSIL Code and Metadata. 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 MSIL code and metadata are located in a “Portable Executable File”.

  • When you execute a portable executable file,the  Class Loader loads the MSIL code and the metadata from the portable executable file into run-time memory.Before the code is executed,it is passed to the native code compiler for compilation.
  • The IL to native code compiler contains just-in-time(JIT) compiler for different CPU architectures and compiles the IL code into a native instruction set.
  •  After the MSIL code and the metadata are loaded into memory,the Code Manager calls entry-point method,which is the Main,WinMain or D11Main method. During the execution of the entry-point method,the code manager places the objects in memory and controls the execution of the program.
  • The Garbage Collector performs periodic checks on the managed heap to identify the objects that are no longer required and removes them from the memory.
  • During program execution,the Type Checker ensures that all objects and values,and the references to those objects and values,have a valid type.
  • The Security Engine of the common language runtime(CLR) enforces restrictions on the code and controls the access to system resources such as hard disk,network connections,and other system resources.
  • The .NET Framework allows a single process to be divided into one or more subprocesses called application domains. Each application domain can contain one or more threads. The run-time monitors all the threads that have executed code within its process.
  • COM Marshaler performs marshaling of data when data passes between managed and unmanaged execution environments. Marshaling manages the different representations of data across different execution environments. It performs the necessary conversions in data formats between managed and unmanaged code.
  • During the execution process, a program depends upon the functionality provided by the .NET Framework class library .The CLR provides Base Class Library Support to the programes that are running within the managed execution process.
  • The CLR also provides a common Debug Engine which enables you to debug an applicationwritten in any language supported by the .NET framework. The common Debug engine supports debugging applications running on local and remote machines.
Categories: .Net, Framework
Follow

Get every new post delivered to your Inbox.