Components of Common Language Runtime

Component of CLR: - Introduction
The Common Language Runtime (CLR) is an Execution Environment. It works as a layer between Operating Systems and the applications written in .Net. The main function of Common Language Runtime (CLR) is to convert the Managed Code into native code and then execute the Program.

The CLR has the following components
1.       Common Type System
2.       Common Language Specification
3.       Microsoft Intermediate Language
4.       Garbage Collector
5.       Code Manager

6.       JIT Compiler - Introduction

Common Type System: - Introduction
A fundamental part of the .NET Framework's Common Language Runtime is the CTS. The CTS defines a common set of types that can be used with many different languages.

Common Type System (CTS) describes a set of types that can be used in different .Net languages in common .The Common Type System (CTS) ensure that objects written in different .Net languages can interact with each other .

The Common Type System (CTS) is a standard for defining and using data types in the .NET framework. CTS define a collection of data types, which are used and managed by the run time to facilitate cross-language integration.

CTS provide the types in the .NET Framework with which .NET applications, components and controls are built in different programming languages so information is shared easily. In contrast to low-level languages like C and C++ where classes/structs have to be used for defining types often used (like date or time), CTS provides a rich hierarchy of such types without the need for any inclusion of header files or libraries in the code.

The common type system supports two general categories of types, each of which is further divided into subcategories:
1.       Value types: - Value types directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in (implemented by the runtime), user-defined, or enumerations. For a list of built-in value types, see the .NET Framework Class Library.

2.       Reference types:-Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. The type of a reference type can be determined from values of self-describing types. Self-describing types are further split into arrays and class types. The class types are user-defined classes, boxed value types, and delegates.

Microsoft Intermediate Language: - Introduction
MSIL stands for Microsoft Intermediate Language. We can call it as Intermediate Language (IL) or Common Intermediate Language (CIL).The VC# compiler translates or builds the source code into Microsoft Intermediate Language (MSIL). This language is stored into a special file. This file is called Assembly. An assembly is simply an executable file that has an .exe or .dll extension.


During the compile time, the compiler convert the source code into Microsoft Intermediate Language (MSIL) .Microsoft Intermediate Language (MSIL) is a CPU-independent set of instructions that can be efficiently converted to the native code.

During the runtime the Common Language Runtime (CLR)'s Just In Time (JIT) compiler converts the Microsoft Intermediate Language (MSIL) code into native code to the Operating System.

When a compiler produces Microsoft Intermediate Language (MSIL), it also produces Metadata. The Microsoft Intermediate Language (MSIL) and Metadata are contained in a portable executable (PE) file.

Microsoft Intermediate Language (MSIL) includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations.


Garbage Collector
The process of removing the objects from the memory which are no longer required is called as Garbage Collection. The .NET garbage collector enables high-speed allocation and release of memory for the objects in managed code. Its main aim is proper memory management.

Code Manager
Code manager invokes class loader for execution. .NET supports two kind of coding 
1.       Managed Code
2.       Unmanaged Code

The code, which is developed in .NET framework, is known as managed code. This code is directly executed by CLR with help of managed code execution. Any language that is written in .NET Framework is managed code.

The code, which is developed outside .NET, Framework is known as unmanaged code. Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such as C++ can be used to write such applications, which, for example, access low - level functions of the operating system

Unmanaged code is executed with help of wrapper classes. Wrapper classes are of two types: CCW (COM Callable wrapper) and RCW (Runtime Callable Wrapper).

JIT Compiler - Introduction
The JIT stands for Just In Compiler. When we run the .Net application the Just In Time (JIT) compiler converts the Microsoft Intermediate Language (MSIL) code into native code to the Operating System.


When we compile a Microsoft.NET language, the complier generates code written in the Microsoft Intermediate Language (MSIL). MSIL is a set of instructions that can quickly be translated into native code.

A Microsoft.NET application can be run only after the MSIL code is translated into native machine code. In .NET Framework, the intermediate language is complied "just in time" (JIT) into native code when the application or component is run.

The Microsoft.NET runtime consists of two JIT compilers. They are standard JIT compiler and the EconoJIT compiler. The EconoJIT compiler compiles faster than the standard JIT compiler, but the code it produces is not as optimized as the code obtained from the standard JIT compiler.




Comments

Popular posts from this blog

Components of Visual Studio IDE

Introduction of .Net Namespace

Introduction to Visual Studio Integrated Development Environment (IDE).